day 2 - unibas.ch · plan day 1 - 'look at the data' • scale, calibrate, re-size,...
TRANSCRIPT
day 2
plan
DAY 1 - 'look at the data'• scale, calibrate, re-size, visualize• histograms, profiles, LUTs• morphological operations• from element maps to phase maps• volume estimates
DAY 2 - 'image analysis basics'• segmentation image → bitmap
POP, NOP, edge detectors• image analysis of segments, best fit ellipses• re-direct sampling• property mapping• texture mapping
DAY 3 - 'all about grain size'• 2D grain size / grain size distribution• 3D grain size / grain size distribution• fractal grain size distribution
DAY 4 - 'all about shape'• paror - orientation of particles• surfor - orientation of surface• ishapes - shapedescriptors
DAY 5 - 'spatial aspects'• FFT - spatial frequencies• ACF - neighbourhood relations• spatial distributions
segmentation
steps in image analysis
recording
analysis
1
23
4
etc.
steps in image analysis
recording
analysis
1
2
34 etc.
segmentation
recording
analysis
steps in image analysis
pre-processing
segmentation
post-processing
image models
models
images
thresholding
segmentation based on image model
grey levelslicing
edgedetection
post-processingranking filters
structural filtering
segmentation: point operation
step 1segmentationbasis = grey value (Z)⇒ bitmap
step 2 structural filtering
Z X
Y
segmentation: neighboorhood operation
high
low
step 1 segmentationbasis = neighboorhood (X,Y)⇒ grey scale image
step 2 thresholding - structural filtering
Z X
Y
ranking filters I
original
minimum median maximum
0 0 0 1 1 1 1 1 1
minimum median maximum
ranked grey values of 3x3 neighbourhood
original
minimum median maximum
0 0 0 0 0 0 0 0 1
minimum median maximum
ranked grey values of 3x3 neighbourhood
ranking filters I
original
0 1 1 1 1 1 1 1 1
minimum median maximum
ranked grey values of 3x3 neighbourhood
minimum median maximum
ranking filters I
original
ranking filters I
median minimum maximum
40 25 23
25 10 15
13 1 5
original
ranking filters I for gray scale images
ranked grey values of 3x3 neighbourhood
1 5 10 13 15 23 25 25 40
minimum median maximum
minimum median maximum
original median minimum maximum
ranking filters I for gray scale images
original set count:1 - erode if 1 is white2 - erode if 2 are whiteetc.
set count:1 - dilate if 1 is black2 - dilate if 2 are blacketc.
ranked grey values of 3x3 neighbourhood
ranking filters II
definition of neighbouring pixels
original
Set Count:1 - erode if 1 of 9 is white2 - erode if 2 of 9 are white....8 - erode if 8 of 9 are white
Set Count:1 - dilate if 1 of 9 is black2 - dilate if 2 of 9 are black....8 - dilate if 8 of 9 are black
strength of operation:
WEAK
STRONG
ranking filters II
ranked grey values of 3x3 neighbourhood
original
erode 7 erode 5 erode 3 erode 1
erosion
ranking filters II
original
dilate 7 dilate 5 dilate 3 dilate 1
dilation
ranking filters II
original
= opening = closing
1. erode2. dilate
1. dilate2. erode
morphological operations
original ultimate points
distance map watershed
morphological operations
logical operations
Logical operations on bitmaps
AND1 0
1 1 00 0 0
1 01 1 10 1 0
1 01 0 10 1 0
1 01 1 00 1 0
image 1
image 1 image 2
imag
e 2
OR
XOR
COPY
(1∪2)
(1∩2)
(1|2)
image addition
1 + 2
1 to 2
COPY 1 to 2
1 AND 2 1 OR 2 1 XOR 2
image 1
- copy & paste control- Image Math...
image 2
Adding two images
shifted copy of 1
shift copy:Δx=+2 Δy=-2
image 1
Adding image and copy of image
1 AND 1 1 OR 1 1 XOR 1
exerciseerode dilate...
exercise
1. open Truzzo2. pre-process (noise) - background - re-size - crop3. background correction4. save
5. Lazy LUT: perform contiguous segmentation 6. make stack of 6 phases7. start pots-processing: morphological filtering
Lazy erodedilate
Macro: Jazy erodilate (imageJ)
post-processingclean up
segmentation
manual cleaning
phase map
invert: phase mask
original
increase brightness
cleaning in stack using phase masks
phase mask + brightness
added OR
continue manualcorrections
thresholdinvert
merge mask and light version
grain maps
z-project/average: 1-5
procedure 1: separate grains ...
4
2 3
6
1
5
yields grain boundaries
grain maps
... derive grain boundaries
4
2 3
6
1
5
using colored grain maps
minimum filter
phase map: no grain boundaries
grain map: grain boundaries = 'phase'
derive phase map from grain map
phase maps
average all(incl. holes & unidentified)
procedure 2: separate phases ...
4
2 3
6
1
5
phase maps
erode phasesaverage
... derive phase boundaries
4
2 3
6
1
5
phase mapgrain map
segmentation based on Z
25 78 106 158 200
originalDensity Slicing = contiguous grey values
Z X
Y
Segments and segment boundaryContiguous areas = spatially contiguous
phase map
10 63 18187 150
255
250 10 63 18187 150
255
250
grain mapphase map
post-processing yields:
compare segmentations
qtz = 26.8%qtz = 28.8%qtz = 29.7%
phase- grain- grain boundary maps
phase phase map6 phases (%)
grain + gb map 7 phases (%)
grain map 5 phases (%)
number of grains
biotite 7.7 6.6 7.3 15
K-feldspar 20.8 18.9 20.7 32
muscovite 2.4 2.0 2.2 7
plagioclase 40.1 36.9 40.4 66
quartz 28.8 26.8 29.4 47
rest 0.13 0.08
grain b 8.7
sum 100.0 100.0 100.0 167
biotite K-feldspar muscovite
plagioclase quartz unidentified
phase boundaries
phase vs. grain boundary maps
all boundaries phase boundaries only
grain boundaries sensu strictu
neighbourhood operations
(NOP)
i-1 / j-1 i / j-1 i+1 / j-1
i-1 / j i / j i+1 / j
i-1 / j+1 i / j+1 i+1 / j+1
3 x 3 neighborhood
introductory example: moving average166 89 72 89 79 82 139 84 22 44 99 131 156 183 193 168
102 49 39 51 62 70 72 31 22 56 124 161 180 205 212 190
70 34 31 62 65 107 114 70 56 72 114 143 180 205 207 171
44 29 24 44 124 92 67 70 56 46 60 151 226 188 141 99
31 29 7 14 84 39 14 27 24 44 114 126 236 219 107 67
24 39 22 9 12 27 19 29 19 54 109 89 183 255 193 97
24 27 24 17 17 39 75 102 82 94 126 141 168 231 231 178
22 22 27 36 19 29 114 121 121 141 168 168 193 207 200 166
19 22 36 41 17 22 60 75 116 107 87 161 193 188 156 129
17 24 56 54 17 14 94 158 97 79 82 89 126 134 119 111
14 27 27 9 12 19 84 156 77 75 102 60 79 104 97 84
12 17 9 2 19 29 54 114 87 89 109 79 79 67 72 94
14 17 14 41 77 99 131 178 151 153 168 139 121 75 65 82
27 36 72 129 156 158 163 200 180 175 195 180 136 49 17 17
29 54 134 180 188 180 158 168 195 190 183 146 107 22 0 2
24 36 97 148 163 175 171 161 168 173 143 99 67 12 7 7
101 86 64 65 72 84 79 61 43 61 102 141 169 188 191 190
85 72 57 61 74 87 85 67 50 67 104 143 171 191 192 190
54 46 40 55 75 85 77 62 53 67 103 148 182 193 179 170
39 33 30 50 70 78 66 55 51 65 96 150 186 189 156 132
32 27 24 37 49 53 42 36 41 58 88 143 185 194 151 117
29 25 20 22 28 36 41 43 52 74 99 143 183 202 175 145
26 25 24 20 22 39 61 75 84 101 121 149 181 206 195 177
22 24 28 26 26 43 70 96 106 115 132 156 183 196 187 176
21 27 35 33 27 42 76 106 112 110 120 140 162 168 156 146
20 26 32 29 22 37 75 101 104 91 93 108 126 132 124 116
18 22 25 22 19 38 80 102 103 88 84 89 90 97 98 96
16 16 18 23 34 58 96 114 120 112 108 104 89 84 82 82
20 24 37 57 78 98 125 139 147 145 143 134 102 75 59 57
29 44 75 110 134 145 159 169 176 176 169 152 108 65 36 30
34 56 98 140 164 168 170 173 178 178 164 139 90 46 14 8
35 62 108 151 172 172 168 170 175 175 155 124 75 35 8 4
30 25 23
25 10 15
13 1 5
10 15
1/9 1/9 1/9
1/9 1/9 1/9
1/9 1/9 1/9
= 1/9· [30 + 25 + ... 5] = 15
1 1 1
1 1 1
1 1 1
·1/9· =
30 25 23
25 10 15
13 1 5
example: moving average
neighborhood operations
averaging filters
3 by 3 moving average
1 1 11 1 11 1 1
≠ median
moving average
0 1 0
1 1 1
0 1 0
1 0 1
0 1 0
1 0 1
influence of shape
1 1 1 1 1 1 1
1 1 1 1 1 1 11 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
influence of size
Gaussian
1 1 2 1 1
1 2 4 2 1
2 4 8 4 2
1 2 4 2 1
1 1 2 1 1
2 2 3 4 5 5 6 6 6 5 5 4 3 2 2
2 3 4 5 7 7 8 8 8 7 7 5 4 3 2
3 4 6 7 9 10 10 11 10 10 9 7 6 4 3
4 5 7 9 10 12 13 13 13 12 10 9 7 5 4
5 7 9 11 13 14 15 16 15 14 13 11 9 7 5
5 7 10 12 14 16 17 18 17 16 14 12 10 7 5
6 8 10 13 15 17 19 19 19 17 15 13 10 8 6
6 8 11 13 16 18 19 20 19 18 16 13 11 8 6
6 8 10 13 15 17 19 19 19 17 15 13 10 8 6
5 7 10 12 14 16 17 18 17 16 14 12 10 7 5
5 7 9 11 13 14 15 16 15 14 13 11 9 7 5
4 5 7 9 10 12 13 13 13 12 10 9 7 5 4
3 4 6 7 9 10 10 11 10 10 9 7 6 4 3
2 3 4 5 7 7 8 8 8 7 7 5 4 3 2
2 2 3 4 5 5 6 6 6 5 5 4 3 2 2
(5x5)
(15x15)
linear filters
5.2 Linear Filters 107
L
L
M
N
KK
H
I
u
v
no coverage
full coverage
Figure 5.7 Border geometry. The filter can be applied only at locations (u, v) where thefilter matrix H of size (2K+1) × (2L+1) is fully contained in the image (inner rectangle).
0
0
0
1
0
1
1
0
1
1
0
0
0
0
0 0 0 0
0 1 1 1 0
0 1
0
1
0
3
1
9
5
2
5
3
1
2
1
0
1 2 1 0
1 3 5 3 1
2 5
0
0
0
-1
0
16
-2
-1
-2
-1
0
-1
0
0
0 -1 0 0
0 -1 -2 -1 0
-1 -2
(a) (b) (c)
Figure 5.8 Typical examples of linear filters, illustrated as 3D plots (top), profiles (center),and approximations by discrete filter matrices (bottom). The “box” filter (a) and the Gaussfilter (b) are both smoothing filters with all-positive coefficients. The “Laplace” or “Mexicanhat” filter (c) is a difference filter. It computes the weighted difference between the centerpixel and the surrounding pixels and thus reacts most strongly to local intensity peaks.
gradient filters
gradient filters
0 -.5 0
0 0 0
0 .5 0
0 0 0
-0.5 0 0.5
0 0 0
0 0 0
0.5 0 -0.5
0 0 0
0 .5 0
0 0 0
0 -.5 0
maxim
um o
f 4
(average of 4)
0 0 00 1 -10 0 0
0 0 01 0 -10 0 0
influence of separation
E-W difference
-1 0 1-1 0 1-1 0 1
-1 -1 -10 0 01 1 1
influence of direction
Shadows
0 0 -10 1 00 0 0
0 -1 00 0 10 0 0
Robert's cross 2 x 2 (gradient / 1st derivative)
- maximum of 4 gradient images- thresholding
Robert's cross 2 x 2 (gradient / 1st derivative)
maximum of 8 directions
Sobel operator
1 2 10 0 0-1 -2 -1
1 0 -12 0 -21 0 -1
-1 -2 -10 0 01 2 1
-1 0 1-2 0 2-1 0 1
-2 -1 0-1 0 10 1 2
0 1 2-1 0 1-2 -1 0
2 1 01 0 -10 -1 -2
0 -1 -21 0 -12 1 0
(1st derivative)
Sobel 3x3
hand-made Sobel
Find edges 5x5
Roberts Cross
0 1 0
1 -4 1
0 1 0
1 1 1
1 -8 1
1 1 1
Laplace operator (2nd derivative)
1 1 1 1 11 1 1 1 1
1 1 -24 1 11 1 1 1 1
1 1 1 1 1
original
-1 -1 -1 -1 -1-1 -1 -1 -1 -1-1 -1 40 -1 -1-1 -1 -1 -1 -1-1 -1 -1 -1 -1
Laplace 5· 5
-1 -1 -1
-1 12 -1
-1 -1 -1
Laplace 3· 3
Laplace for sharpening
1 1 2 1 11 2 4 2 12 4 8 4 21 2 4 2 11 1 2 1 1
-1 -1 -2 -1 -1-1 -2 -4 -2 -1-2 -4 44 -4 -2-1 -2 -4 -2 -1-1 -1 -2 -1 -1
Gauss 5x5
Laplace 5x5
-1 -1 -2 -1 -1-1 -2 -4 -2 -1-2 -4 88 -4 -2-1 -2 -4 -2 -1-1 -1 -2 -1 -1
-1 -1 -1 -1 -1-1 -1 -1 -1 -1-1 -1 24 -1 -1-1 -1 -1 -1 -1-1 -1 -1 -1 -1
-1 -1 -1 -1 -1-1 -1 -1 -1 -1-1 -1 48 -1 -1-1 -1 -1 -1 -1-1 -1 -1 -1 -1
Laplace for sharpening
Laplace for edge detection
-1 -1 -1-1 8 -1-1 -1 -1
-1 -1 -1-1 8 -1-1 -1 -1Laplace 3· 3
Laplace 3· 3
Difference: Gaussian - Original
original
Gauss 15 x 15
difference, equalized
original
Gauss 15X15
difference
image horizontal traverse
Difference: Gaussian - Original
exerciseConvolve...
exercise
1. open Parrot_P_64.tif and parrot_test.tif2. enlarge window to 200%3. convolve with filter kernels4. watch little test figure5. watch histogram
Lazy grainboundaries
Lazy grain boundaries input
RGB colour image
Lazy grain boundariesearth.unibas.ch/micro
Uses different versions of same image.Originally written to analyze a • stack of misorientation images or• differently polarized imagesbut can also be used for any• multichannel image e.g. RGB stack
Image SXM and Fiji / imageJ
'orientation' images (5 types)
crosspol crosspolcirpol
azi / inc misoredge
Lazy grain boundaries: input images
use stack
set of misorientation images
Lazy grain boundaries
cuo
Lazy grain boundaries
cuog-z-m
Lazy grain boundaries
cuog-z-m-ji-tji-tji
Lazy grain boundaries
cuog-z-m-ji-tji-tji-t5y
Lazy grain boundaries
typical artefactsof segmentation:
• corner of 4• oversegmentation• 45° diagonals
→ 2000_RH_Lazygbd_JSG.pdf
Lazy grain boundaries
exerciseLazy
grainboundaries
exercise
1. open RubyGap image2. try Lazy grainboundaries
3. open stack of misorientation images (2w920misor)4. try Lazy grainboundaries
Image SXMAnalyze
Analyze
define measurements
Area- no. of pixels- scaled area
Image SXM Analyze
X-Y centercenter of gravity
Image SXM Analyze
Perimeter/Lengthlength of perimeter
Image SXM Analyze
Ellipse Major AxisEllipse Minor Axis
Image SXM Analyze
AngleAngle of Major Axisw/r to horizontal
Image SXM Analyze
A
A! ! = Arequ! (equivalent radius)! = √ (A / π)dequ! (equivalent diameter)! = 2· √ (A / π)Pequ! (equivalent perimeter)! = 2· √ (π· A)
A
requ
dequ
Pequ derived measures
a (major diameter)
b (minor diameter)
P (perimeter length)
A (area)
"Len"
"Minr"
"Majr"
"Area"
φ (orientation of a)
positive x = 0°CCLW = positive
"Angle"
φ
best fit ellipse
requ, a, b,! size (linear)
b / a ≤ 1! axial ratio, flattening, ..
a / b ≥ 1! aspect ratio, elongation, ...
P / Pequ ≥ 1! circularity, sphericity, ...! lobateness, angularity, convexity, ...! ("fractal dimension")
shape descriptors - shape factors
Image SXMAnalyze
Analyze
define measurements
ImageJ Analyze
Fiji - Set Measurements
Area, Gray value distributionArea:Area of selection in square pixels or in calibrated units.
Mean (= Mean Gray Value):Average gray value within the selection (0-255) or calibrated units.
StdDev (= Standard Deviation):Standard deviation of the gray values used to generate the mean gray value.
Mode (= Modal Gray Value):Most frequently occurring gray value within the selection (highest peak in the histogram).
Min, Max (= Minium and Maximum Gray Level):Minimum and maximum gray values within the selection.
1 32
Shape & x-y coordinates of segmentsX, Y (= Centroid):Average of the x and y coordinates of all of the pixels in the image or selection.
XM, YM (= Center of Mass):Brightness-weighted average of the x and y coordinates all pixels in the image or selection.
Perim. (= Perimeter):The length of the outside boundary of the selection.
BY, BM, Width, Height (= Bounding Rectangle):The smallest rectangle enclosing the selection: BX and BY are the coordinates of the upper left corner of the rectangle.
1 32
1 32
Best fit ellipseMajor, Minor, Angle (= Best Fit Ellipse):
Major is long diameter (2a)Minor is short diameter (2b)
Angle (0° - 180°) is the angle between the major axis and the x-axis (0°) counting counterclockwise.
The coordinates of the center of the ellipse are X and Y (= Centroid)
2
Edit>Selection>Fit Ellipse:
1 32
Shape descriptorsCirc. (= Circularity): area / area of perimeter-equivalent circle.
AR (= Aspect ratio): major_axis / minor_axis.
Round (= Roundness): 4*area / (π*major_axis^2) = the inverse of the aspect ratio.
Solidity: area / convex area.
1
Edit>Selection>Convex Hull:
1 32
Caliper diametersFeret (= Feret's Diameter) (= maximum caliper):The longest distance between any two points along the selection boundary.
FeretAngle (0°-180°):The angle between the Feret's diameter and the x-axis.
FeretX, FeretY:The starting coordinates of the Feret's diameter.
MinFeret (= minimum caliper):The minimum caliper diameter
Density measuresIntDen, RawIntDen (= Integrated Density):"IntDen" = the product of Area and Mean Gray Value"RawIntDen" = the sum of the values of the pixels in the image or selection
Median:The median value of the pixels in the image or selection.
Skewness, KurtosisThe third order moment about the mean.The fourth order moment about the mean.
Area FractionThe percentage of pixels in the image or selection that have been highlighted in red using Image>Adjust>Threshold. For non-thresholded images, the percentage of non-zero pixels.
Kaleidagraph plotting results
deriving shape descriptors
1:1
shape descriptors: axial ratio b/a
mean of b/a: 0.62565
c8=c7/c6
slope of b vs. a: 0.63447
shape descriptors: axial ratio b/a
c2=sqrt(c1/pi)
shape descriptor: b/a as f(requ)
1.0
1.5
2.0
2.5
3.0
3.5
4.0
0 45 90 135 180
TruzzoHighMagNoSc100
a/b
Angle
Rf - φ diagram
shape descriptor
fractal dimension: 1.2156
shape descriptor: P / Pequ
b/a
comparison: quartz - plagioclase
b/a(requ)
comparison: quartz - plagioclase
Rf-φ
comparison: quartz - plagioclase
P/Pequ
comparison: quartz - plagioclase
exerciseimage analysis
exercise
1. open Meluzina M32. perform image analysis type 2 and 33. plot results
4. open TOSsedi EPI and TRANS5. make bitmap of TRANS6. perform image analysis type 2 and 3 using re-direct
TOS sediMOTIVATION:
Use two scans of same sand:! transmission mode - for bitmap! incident light - color, grey values
Use Re-direct sampling to analyze all aspects of shape and surface texture (color)
1.! Open images!! RGB opens as stack and Index image
2.! Check scale!scale if necessary
3.! Extract Green Channel!! Stacks > Stack to Windows! keep 002 (G = green channel)! discard Index image! discard 001 (R) and 003 (B)
4.! Analyze > Options!check all ...!
5.! Analyze > Analyze Particles...
6.! Analyze > Show Results! File > Save As...
TOS_2_bit TOS_2_epiG (green channel of RGB)
TOS sedi7.! Kaleidagraph! if applicable, delete last particle ( = scale bar)
7.1! Functions > Bin Data...!! make histogram of "Majr" (=long axis of best fit ellipse)
7.2! calculate Pequ ! Data > Insert Column after "Len" (=measured perimeter)! !! ⌘F = Formula Entry
7.3! plot Pequ against Len!! Gallery > Scatter Plot
7.4! make line fit! Curve Fit > Linear Plot! !7.5! force through zero! Curve Fit > Curve Fit Options...
Plot
TOS sedi8.! Map Properties!! Macros > Load Macros: Lazy Grain Mapping!! if applicable, turn OFF Re-direct Sampling!! in Analyze > Options...!! Select area (ROI) without scale!! ⌘D Duplicate! File > Save As... TOS_2_bit_crop.tif
8.1! [B] Size Map! Max radius = 1.19 mm
8.2! [F] Shape factor Map! Max shape factor = 1.55
(Detail of TOS_2_bit_cropB)
(Detail of TOS_2_bit_cropF)
TOS sedi8.3! Threshold maps! [B] Size Map at requ > 0.5mm (dequ > 1mm)! [F] Shape factor Map at SF1 > 1.25
8.4! Interesect! TOS_2_bit cropF>1.25.tif! TOS_2_bit crop B>05.tif
! =>! r > 0.5 mm AND P/Pequ > 1.25
SF1 > 1.25 requ > 0.5 mm