Demo iadconcrete

Aggregate and anhydrous phase extraction from a concrete section observed by a SEM image.


This example shows an image analysis technique to detect anhydrous phase and aggregate from a polished concrete section observed by scanning electron microscope (SEM). The anhydrous phase appears as white grains while the aggregate appears in the image as an homogeneous medium-gray grains. This image was kindly provided by Prof. Gladis Camarini from FEC-UNICAMP. The steps for this analysis are: i) anhydrous detection by automatic threshold analysis; ii) homogeneous grain detection using watershed technique; iii) aggregate are homogeneous grains that are not from the anhydrous phase. The automatic threshold analysis is done using 1D-signal morphological processing using watershed.



The SEM image of a polished concrete section is read. The anhydrous phase are the white pores, while the aggregate are the medium-gray homogeneous pores.

1. from ia870 import *
2. import ia636 as ia
4. f = adreadgray('csample.jpg')
5. print ia.iaimginfo(f)
6. adshow(f)
<type 'numpy.ndarray'> (480, 640) uint8 0 255


The histogram has a small peak in the white region related to the anhydrous phase.

1. import ia636
2. h = ia636.iahistogram(f).astype('uint16')
3. adshow(ia636.iaplot(h))

Automatic threshold from histogram

The threshold value is extracted using the watershed technique. The aim is to detect the middle valley of the histogram. If the histogram is negated, we need to extract the middle peak of the 1D signal. This is accomplished by find proper markers on the valleys. These markers are extracted by detecting the regional minima of the filtered signal (alternating sequential filtering, closing followed by opening of length 5 pixels). To discard the detection of peaks near the limits of the histogram, the second watershed line is selected. For illustrative purpose, a plot of all the signals involved is displayed.

1. hf = iaasf(ianeg(h),'co',iaseline(5))
2. ws = iawatershed(hf)
3. t = nonzero(ravel(ws))[0][1]
4. print 'threshold=',t
5. mmax = h.max()
6. hf_plot = ianeg(ravel(hf))
7. ws_plot = iagray(ravel(ws), 'uint16', mmax)
8. adshow(ia636.iaplot([hf_plot,ws_plot]))
threshold= 187

Anhydrous using thresholding and filtering

The threshold value found in the previous step is applied. After, a filter to remove blobs smaller then 20 pixels is applied. For illustrative, the contour of the anhydrous grains are displayed as an overlay on the original image.

1. t1 = time.time()
2. aux = f >= t
3. anidro = iaareaopen(aux, 20)
4. mm_anidro = mmareaopen(aux,20)
5. adshow( iagshow( f, anidro),'anhydrous')
6. adshow( iagshow( f, iagradm(anidro)),'contour')
7. print time.time() - t1, 'seconds'
2.52563405037 seconds



Homogeneous regions

The watershed applied on the gradient using the markers from filtered regional minima of the gradient is a standard watershed based technique. In this case the filter was chosen to be a contrast iahmin.

1. t1 = time.time()
2. g=iagradm(f)
3. m=iaregmin(iahmin(g,10))
4. ws=iacwatershed(g,m)
5. print time.time() - t1, 'seconds'
6. adshow(ws)
8.08152222633 seconds

Aggregate detection

The result of the watershed in the previous step is the detection of a large number of regions. The larger ones are the aggregate and the anhydrous. So first the regions are filtered out using an area criterion of 300 pixels. Small holes (area <= 50) are closed. The aggregate is obtained by removing the anhydrous phase.

1. t1 = time.time()
2. aux1=iaareaopen(ianeg(ws),300)
3. aux2=iaareaclose(aux1,50)
4. aggr=iasubm(aux2,anidro)
5. adshow(iagshow(f,aggr),'aggregate')
6. print time.time() - t1, 'seconds'
7. adshow(iagshow(f, iagradm(aggr)),'contour')
21.6794979572 seconds



Measurement and display

Finally each phase is measured and an illustrative display is constructed. The grains contoured by red are the aggregate and those contoured by green, the anhydrous.

1. n = product(shape(f))
2. anidro_phase = 1.0 * anidro.sum()/n
3. print 'anidro=',anidro_phase
4. aggr_phase = 1.0 * aggr.sum()/n
5. print 'aggr=',aggr_phase
6. adshow( iagshow( f, iagradm(aggr), iagradm(anidro)),'aggregate:%.2f %% (red), anhydrous:%.2f %% (green)' % (aggr_phase,anidro_phase))
anidro= 0.112887369792
aggr= 0.256572265625

aggregate:0.26 % (red), anhydrous:0.11 % (green)