Blob Colorize
The Blob Colorize module provides a way to recolorize blobs (segmented objects) based on another image (normally the
source pixel data). This is required when you have processed an image into separated blobs but need to recombine
the blobs with their original color information that was lost during processing.
The Blob Colorize will use a source pixel image and replace each non-black object with the various colors
drawn from the source image. This is functionally similar to using the blobs as masks into the source pixel
image and summing the resulting pixels to form the new color.
Interface
Instructions
1. Source - Select which image represents the source pre-processed RGB pixel image of the current image.
2. Color - Select which color statistic to gather based on the source image that will be the new color
of the respective blob. When nearest is selected the bottom part of the GUI interface will be enabled.
3. Label - specify the name of the color (as will be used in the variable array) such that you can
easily identify a color based on a name as apposed to an RGB triplet.
4. Add X - add in colors as needed in order to create a list of colors that will be matched against. For
each detected blob in the image the color those most closely matches that blobs color will become
that blobs color. This allows an almost white or almost red blob to become pure white or pure red assuming
that you have both white and red as "Nearest Colors".
5. Match Threshold - specify how closely a color should match one of the "Nearest Colors" to be replaced
with that color.
Example
| Source | Blob Colorize |
 |  |
The above demonstrates the blob colorizing routine after thresholding the image for high intensity, dilating by
2 and then using the blob colorizing module to recolor the resulting white blobs.
This technique is very handy for laser light detection. The issue with laser lights is that while we see them as
red (or green) but the camera sees them as white light surrounded by a red halo due to the color range limitation of CCDs. In order to detect "red" spots we
need to first detect likely laser spots, expand the blob and then test for color. The following shows
two laser lights from the SRV-1 robot and the final step of
the detected two laser lights with the X coordinate of the blobs (this can be used for distance sensing).
Download the robofile that accomplishes this.
| Source | Laser Detected |
 |  |
Variables
BLOB_COLORIZE_LABELS - contains an array of matched color information for each blob.
The array contains blocks of 6 values per colorized blob. The elements
are as follows:
Offset Contents
0 x coordinate of the center of gravity of the blob
1 y coordinate of the center of gravity of the blob
2 hex formatted color information or label (when nearest color used)
3 Red color value
4 Blue color value
5 Green color value
For example, to look for red colored blobs you could now use
labels = GetArrayVariable("BLOB_COLORIZE_LABELS")
for i = 0 to ubound(labels)-1 step 6
if labels(i+3) = "255" and labels(i+4) = "0" and labels(i+5) = "0" then
write "Found a red blob" & vbCRLF
end if
next
See Also
Colorize
|