Segment an image using two-dimensional pixel classification.
class_2dim__ classifies the points in two-channel images using a two-dimensional feature space. For each point, two gray values (one from each image) are used as features. The feature space is represented by the input region. The classification is done as follows:
A point from the input region of an image is accepted if the point (g_{c},g_{l}), which is determined by the respective gray values, is contained in the region FeatureSpace. Here, g_{l} is a gray value from the image ImageRow, while g_{c} is the corresponding gray value from ImageCol.
Let P be a point with the coordinates P=(L,C), g_{l} be the gray value at position (L,C) in the image ImageRow, and g_{c} be the gray value at position (L,C) in the image ImageCol. Then the point P is aggregated into the output region if
(g_c,g_l) is an element of FeatureSpaceHence, g_{l} is interpreted as row coordinate and g_{c} as colum coordinate.
For the generation of FeatureSpace, see histo_2dim__. The feature space can be modified by applying region transformation operators, such as count, dilation1, shape_trans, elliptic_axis, etc., before calling class_2dim__.
The parameters ImageCol and ImageRow must contain an equal number of images with the same respective size. The image points are taken from the intersection of the domains of both images (see reduce_domain).
ImageCol (input_object) |
image(-array) -> object : byte |
Input image (first channel). |
ImageRow (input_object) |
image(-array) -> object : byte |
Input image (second channel). |
FeatureSpace (input_object) |
region -> object |
Region defining the feature space. |
RegionClass2Dim (output_object) |
region(-array) -> object |
Classified regions. |
#include "HCPP.H" #includeint main (int argc, char *argv[]) { if (argc != 2) { cout << "Usage : " << argv[0] << " 'image' " << endl; return (-1); } HRegion feats, cd2reg; HImage image (argv[1]), text1, text2, mean1, mean2, histo; HWindow win; long nc; if ((nc = image.CountChannels ()) != 3) { cout << argv[1] << " is not a rbg-image " << endl; return (-2); } image.Display (win); win.SetColor ("green"); cout << "Draw the region of interrest " << endl; HRegion region = win.DrawRegion (); text1 = image.LawsByte ("el", 2, 5); mean1 = text1.Mean (21, 21); text2 = mean1.LawsByte ("es", 2, 5); mean2 = text2.Mean (21, 21); text1.Clear (); text2.Clear (); histo = region.Histo2dim (mean1, mean2); feats = histo.Threshold (1.0, 1000000.0); win.SetDraw ("fill"); win.SetColor ("red"); feats.Display (win); cout << "Charakteristics area in red" << endl; cd2reg = mean1.Class2dim (mean2, feats); win.SetColor ("blue"); cd2reg.Display (win); cout << "Result of classification in blue " << endl; win.Click (); return (0); }
Let F be the area of the input region. Then the runtime complexity is O(256^2 + F).
class_2dim__ always returns TRUE. The behaviour with respect to the input images and output regions can be determined by setting the values of the flags 'no_object_result', 'empty_region_result', and 'store_empty_region' with set_system. If necessary, an exception is raised.
histo_2dim__, threshold__, draw_region, dilation1, opening, shape_trans
connection, select_shape, select_grey__
class_ndim1__, class_ndim2__, threshold__, histo_2dim__