PD Stefan Bosse
University of Siegen - Dept. Maschinenbau
University of Bremen - Dept. Mathematics and Computer Science
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing -
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Feature Classes
Machine Learning is commonly a data-driven approximation of a functional model f(x):x → y, with x as input and +y* as output (target) features.
There are basically two different ML tasks:
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Feature Classes
Examples for categorical features:
Examples for numerical features:
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Image Classes
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Image Classes
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Image Classes
https://www.matsusada.com/column/ct-tech2.html DICOM CT scan data file format merging meta and raw image data
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Image Feature Extraction
Target output features can be predicted by the data-driven model basically in two ways:
Examples of computed image features:
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Image Feature Extraction
(Left) Microgrpah image of a material slice with pores/impurities (Middle) Edge detection using a Canny filter (Right) Shape characterisation by ellipse fitting
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Image Feature Extraction
(left) Die casted aluminum plate with pores (Center) Single projection X-ray image of plate (Right) Pore marking by semantic pixel classifier (white=pore feature)
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Workflow for Object Feature Detection
Data: Micrograph images of material slices from rectangular probes proced with Additive Manufacturing technologies (metal powder laser melting).
Object Features: Elliptical pores (impurities) characterised by varying size (axis lengths of ellipse), orientation, density, and spatial distribution (inhomogeneity)
Target Features: Statistical and geometrical characterisation of pores, material density, distribution of defects
Feature extraction should be scale, intensity, and position invariant! I.e., object detection should be possible for objects of different sizes, orientation, and position within the images and different image exposures.
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Workflow for Object Feature Detection
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Image Binarization
I1b(x,y)={1I(x,y)≥Ithr0I(x,y)<IthrI0b(x,y)={1I(x,y)≤Ithr0I(x,y)>Ithr
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Image Binarization
i1 = load.image('http://edu-9.de/uploads/assets/pores_microslice_ti_1.png',format='RGBA')m1 = as.matrix(i1,mode='uint8')print(minMax(m1[100:200,100:200]))m1.binary = matrix(255,nrow(m1),ncol(m1),mode='uint8')m1.binary[m1>100]=0plot(m1.binary)
R+ microslice image pre-processing: Normalization and Binarization (0/255)
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Edge Detection with Canny Filter
DOI:10.1109/ICSMC.2009.5346873 Canny edge detection algorithm
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Edge Detection with Canny Filter
use math,imager,ploti1 = load.image('http://edu-9.de/uploads/assets/pores_microslice_ti_1.png',format='GRAY')m1 = as.matrix(i1,mode='uint8')m1.stats = minMax(m1)m1.stats$mean = mean(m1)m1 = (m1 - m1.stats$min)m1[m1>100] = 255print(m1.stats)plot(m1)
R+ microslice image pre-processing: Normalization and Binarization (0/255)
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Edge Detection with Canny Filter
use math,imager,plotm1.edges=cannyEdges(m1,t1=50)plot(m1.edges)
Canny edge filter in R+
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Point Clustering using DBSCAN
https://medium.com/@agarwalvibhor84/lets-cluster-data-points-using-dbscan-278c5459bee5 Three point classes: Core, Border, Noise
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Point Clustering using DBSCAN
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Point Clustering using DBSCAN
DBSCAN Algorithm
Initially, the algorithm begins by selecting a point randomly uniformly from the set of data points. Checks if the selected point is a core point. Again, a point is a core point if it contains at least MinPoints number of minimum points in its epsilon-neighborhood.
Then, finds the connected components of all the core points, ignoring non-core points.
Assign each non-core point to the nearest cluster if the cluster is its epsilon-neighbor. Otherwise, assign it to noise.
The algorithm stops when it explores all the points one by one and classifies them as either core, border or noise point.
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - ROI Bounding Box Approximation from point list
Output from DBSCAN: List of point groups from canny edge filter
Calculate rectangular (not rotated) average bounding boxes (pore boundary point group)
An initial ROI (red) positioned at the center of mass of a point cluster is expanded iteratively by increasing one side and computing the point sum along this side. If the line is empty, the next side is expanded.
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - ROI Bounding Box Approximation from point list
use math, imager, plotpxs = { [1,2], [3,9], [4,7]}pxs.bbox = bbox(pxs)print(pxs.bbox)
Example of a bbox calculation from a pixel set list
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Ellipse Fitting from point list
Problem: Calculate the parameters of an ellipse equation for a set of boundary points.
Halı́ř, FLusser, Numerically stable direct least squares fitting of an ellipse
F(x,y)=ax2+bxy+cy2+dx+ey+f=0b2−4ac<0
with a,b,c,d,e, and f coefficients.
→a=[a,b,c,d,e,f]T→x=[x2,xy,y2,x,y,1]
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Ellipse Fitting from point list
The ellipse-specific fitting problem for a set of points p can be reformulated as:
mina∣∣∣∣^D→a∣∣∣∣2,→aT^C→a=1
with D as the design matrix containing expanded ellipse equation terms, one row for each point:
^D=⎛⎜⎝x21x1y1y21x1y11............x2nxnyny2nxnyn1⎞⎟⎠
and C is a 6 × 6 constraint matrix (independent from the number of points).
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Ellipse Fitting from point list
The minimization problem is ready to be solved by a quadratically constrained least squares minimization.
We get a solution of the minimization problem by solving the Eigenvalue Problem, getting the Eigenvectors, and applying some filtering (only positive Eigenvalue are selected)
mina∣∣∣∣^D→a∣∣∣∣2,→aT^DT→a=λ→aT^C→a=λ
%% Pseudo Code!function fit_ellipse(x, y) { D = [x.*x x.*y y.*y x y ones(size(x))]; % design matrix S = D’ * D; % scatter matrix C(6, 6) = 0; C(1, 3) = 2; C(2, 2) = -1; C(3, 1) = 2; % constraint matrix [gevec, geval] = eig(inv(S) * C); % solve eigensystem [PosR, PosC] = find(geval > 0 & ̃isinf(geval)); % find positive eigenvalue a = gevec(:, PosC); % corresponding eigenvector a}
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Ellipse Fitting from point list
Examples of results from the Canny-DBSCAN-ROI-ElliFit workflow for a ADM micrograph image
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Ellipse Features
Solving the general ellipse equation delivers six polynomial parameters. But relevant for pore analysis are the following parameters:
Major and minor axis lengths w and h
Orientation angle of the major axis θ
Area A of the ellipse
Center coordinates
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Ellipse Features
These parameters can be derived from the general equation parameters:
cx=2cd−beb2−4accy=2ae−dbb2−4acw=√−4fac+cd2+ae24ac2h=√−4fac+cd2+ae24a2cθ=tan−1(2ba−c)3604π
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Statistical Analysis
Average Density (from binarized image)
Average pore size (from ellipse fitting), aspect ratio w/h, variance of these features
Average pore orientation
Spatial distribution of pores
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Data-driven Modelling and Machine Learning
Khan et al., 2018 (Top) Training of a data-driven machine model (Bottom) Application and inference
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Convolutional Neural Networks
Convolutional Neural Networks combine typically:
Multi-dimensional matrix convolution with arbitrarily sized filter kernels
Fully connected neural node layers
Pooling layers
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - CNN Architecture
Ragav Venkatesan and Baoxin Li,2018 Examples of CNN architecture consisting of interlacing different class layers
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Convolutional Neural Networks
Khan et al., 2018 The relation between human vision, computer vision, machine learning, deep learning, and CNNs.
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Vector, Matrix, and Tensor Data
A vector is commonly a linear list of values (real or complex type):
→x=[v1,v2,..,vn]→a⊙→b=[c1,c2,ci,..,cn],ci=ai⋅bi,n=|a|=|b|→x⋅→w=n∑i=1xiwi,n=|x|=|w|
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Vector, Matrix, and Tensor Data
^m=⎡⎢⎣v1,1v1,2..v1,i........vj,1vj,2..vj,i⎤⎥⎦^a⊗^b=n∑i=1m∑j=1ai,jbj,i,n=rows(a),m=cols(b)
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Vector, Matrix, and Tensor Data
A scalar is a level zero tensor.
A vector is an array of numbers along an axis (level one tensor).
A matrix is an arrangement of numbers along two axes (level two tensor).
A tensor is an arrangement of numbers along n axes.
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Vector, Matrix, and Tensor Data
Volumes are (here) three-dimensional data structures representing vectors, 2D matrix, and 3D tensor objects.
A volume is a packed linear array of values with a 321 Layout:
Input, intermediate, output and kernel data can be represented by volumes
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Vector, Matrix, and Tensor Data
Packed linear data model (memory layout) of 3D volumes
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Vector, Matrix, and Tensor Data
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Convolutional Layer
In contrast to kernel-based filtering operations using commonly 3 × 3 two-dimensional filters, convolution can be performed here with any kernel size and dimension.
In contrast to kernel-based filtering operations, the kernel parameters (weights) are not pre-determined. They are evolved during the ML training process.
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Convolutional Layer
Convolution with N filters applied to one input image (stride: shift of filter position in each dimension)
PD Stefan Bosse - AFEML - Module D: Machine Learning in Image Processing - Example: Handwritten Digit Recognition
Ragav Venkatesan and Baoxin Li,2018 CNN layers and configuration for handwritten digit recognition (using the MNIST data set consisting of 28 × 28 × 1 images)