Image Segmentation using
Lispix
Illustration of "Stitching" and "Joining"
- Bottom Segment of Blob Tool
Before Lispix can extract any morphological information from
the images, the images must be segmented – that is, the computer must be told
what is particle, what is annotation, and what is background. This is usually
obvious to the eye, but not so obvious to the computer. Images are segmented
when the pixels are assigned either to background or objects of interest.
Lispix is used to segment the images of particles, with the following steps:
- Pre-process the image, if necessary, so that the blobbing step
gives a fair outline. The outline need not be perfect, and will likely need
patching, which is done in the last step. Preprocessing depends on the nature
of the images, which might depend on the sample treatment or on the instrument
that took the images. Typical pre-processing steps are:
- Flatten. This keeps the edge of the particle intact, but changes smoothly
varying background to a uniform gray level. Good for shadows. See Example
1.
- Edge finder. Occasionally useful for highly textured backgrounds. See
Example 2.
- Blob the image.
- Manually select the brightness thresholds (limits) with a slider.
- Set the minimum size for a blob (a contiguous area of pixels, all of
which fall within the brightness thresholds).
- Input whether or not any blobs area allowed to touch the edge of the
field of view.
- Blob the image.
- Exclude any blobs that are not part of the particle.
- Patch Use the "stitch"
and "join" tools to make the particle outline
conform to the visual outline in the image.
- Often, due texture of the particle surface and the background, the outline
will leave the real or visual outline of the particle and wander around,
either inside or outside the particle, only to return to the real outline
at a nearby spot. The stitch tool removes the excess outline.
- Sometimes, the particle is split into two or more blobs. The join tool
attaches these together.
- Sometimes, if the image is noisy, the outline will have lots of tiny,
obviously incorrect wiggles. These can be removed by smoothing - or coordinate
averaging the boundary points. This step was not done with the outlines
on this CD. Morphological parameters affected by these wiggles are the
perimeter, and the fractal dimensions for small step sizes. Everything
else should not be much affected by the little wiggles.
The examples that follow illustrate these steps.
Segmentation Example 1: Typical
SEM Image of a Particle
Preprocessing
- + (To expand
the menu bar).
- R / demo images (To conveniently set the read directory
to the demo images in /lx-images.
- File / open / potato.jpg (Select and open the image).
This image is highly shaded. Thresholding fails miserably.
- Palette / threshold slider
Sliding the left part of the red bar in the threshold slider selects more
of the bottom of the particle, but the top is drowned in the background. Flattening
takes care of this:
- TOOLS / *particle fractal* / flatten! / Use
the default of a 10-pixel radius. (If this image were taken at twice the
resolution, i.e. 1024x1024 rather than 512x512, then a 20-pixel radius would
be suitable.)
The flattened image looks like this:
Some of the "3D" shape of the particle is now gone, but the background
has more uniform intensity - thresholding will reasonably outline the particle:
Threshold the image using either:
- Palette / threshold slider to make a new threshold slider, or
- th-M002S-2-f10 / ?windows? / front window to use the old threshold
slider.
- Adjust the slider until the OUTLINE of the particle is mostly red:
Now, blob the image:
- TOOLS / Blob Makes the Blobbing Tool button window.
- blob img! Selects the image just thresholded.
- Blob / blob
The particle is not outlined at all.
Chances
are that the blob containing the particle 'leaks' over to the edge of the
image at some point.
- Blob / edge? (see red arrow above). This will allow the particle
blob to touch the edge of the image.
Also, note here that the blobs that were found are considerably smaller than
the particle. Avoid excluding these by hand later by increasing the minimum
blob size:
- Blob / min area! / 5000. 5000 is a good guess. The number is not
at all critical, so long as it is not greater than the area of the particle.
- Blob / blob This is a new blobbing operation, and erases the old
blob results.
It looks as if this outline follows most of the visual particle outline.
To examine and clean it up:
- Click on the original image
- **blob buttons** / draw img! The outline will be taken from the
flattened image, but drawn on this image for comparison with the "real"
or visual outline.
- g! Shows the image in grayscale.
- P! Draws the outlines of the blobs. There are two of them.
- L! Draws the blob labels.
- ** blob buttons** / select blobs / exclude blobs / 1 Excludes blob
1, which is not part of the particle.
- Palette / gamma slider . Adjust slightly to the left to lighten
up the image so that the visual particle outline is easier to see. (green
arrow below).
- P! Draw the outline again.
- Notes: use g! or R! to clear old outlines. g! reverts
to the original grayscale of the image. R! will retain any contrast
enhancement (Palette / contrast or gamma slider) or false color
(Palette / thermal slider).
The yellow line (blob outline) deviates from the particle boundary at two
points (red arrows).
To better show the procedure, zoom the image x4. Zooming occurs about the
center of the image. So as to not get 'lost',
- Drag / Click so that button says Drag is on. This means
that the image can be dragged with the mouse.
- Drag the lower gap (lower red arrow above) to the center of the window
- Zoom the window x4 with either one of these steps:
- Zoom / 4
- + + + + (Each '+' click zooms the image
up by square root of 2.)
The circle below marks the gap where the outline diverges to the interior
of the particle.
Sometimes the gap is easier to see by plotting the averaged outline:
Stitching a Gap in the outline.
Replot the actual perimeter, and click on either side of the gap to 'stitch'
it up:
- R! Erases the smoothed outline.
- P! Draws perimeter
- sel2! Next two clicks will be two points on the outline. (red arrow
1)
- Click on either side of the gap. (red arrows 2 and 3).
Clicking 'rev' shows either half of the now split outline.
This is the desired (exterior) half.
- rev! Shows the undesired (interior) half.
Click 'rev' so that the exterior part is shown, and then 'stitch'
to close up the gap.
Note: Be sure to use rev! a time or two BEFORE 'stitch' to
make sure you are keeping the desired piece of the outline. 'Undo!' might
work in case you don't. Also, if an outline requires work, saving versions
periodically might be prudent: blob / save to file.
Now the exterior excursion(s) of the outline remain. There is some ambiguity
at the upper red arrow.
Showing the smoothed outline resolves the ambiguity:
- R! erases old outline (above)
- AvP / draw (real) draws the smoothed outline.
- (To compare the two directly, R!, P!, AvP. This does not erase
the first outline, P!, before drawing the second. You can change the color
of the second outline:
- Color / {select your color}
- ** blob buttons ** / perim!
Clicking on each side of the neck and stitching results in the pretty much
cleaned up outline.
- sel!
- Click on each side of the neck.
- rev! as appropriate
- stitch!
Note - dragging or zooming the image will erase the outline. Redraw by clicking
on the appropriate button.
How much more of the outline to clean up is a matter of judgment. For example,
the straight edges marked in red look to me to be obscured by collodion:
The stitch function draws a straight line between the selected points, which
is appropriate in this case. Otherwise, the 'drw!' button allows manual drawing
between the selected circles.
Repeated cycling of R! and P! allows examining of other areas
of the boundary that might need fixing, such as that within the red oval above.
Both of these indentations in the yellow boundary are due to surface cracks
or indentations, and not due to a true indentation in the outline of the particle.
Fixing these and a few other places results in the cleaned up outline, representative
of what is in the outl6 folder.
Smoothing the outline, which is visually more appropriate, can also be done.
I did not do this with any of the outlines in the outl6 folder.
- Step Len! / 10 A guess as to a reasonable amount of smoothing for
what appears to be noise induced wiggles in the particle outline.
- AvP / Plot (int) View the smoothed outline as it will be stored.
- AvP / Smooth Replace the original outline with the smoothed one.
Once the outline is smoothed, the new outline can be stored (Blob / Save
to file) and used for morphological measurements. This should be done
with care, as fine texture or wiggles in the boundary that are real data,
might be lost. That is why I did not smooth the boundaries at all. There are
instances of particles taken at higher resolutions, where there appears to
be a lot of empty magnification. The small wiggles in these boundaries are
clearly due to noise, and could be smoothed out.