need explaination in watershed program
In the Watershed based segmentation program , I need to know how the following part works
vector<Vec3b> colorTab;
for( i = 0; i < compCount; i++ )
{
int b = theRNG().uniform(0, 255);
int g = theRNG().uniform(0, 255);
int r = theRNG().uniform(0, 255);
colorTab.push_back(Vec3b((uchar)b, (uchar)g, (uchar)r));
}
and
// paint the watershed image
for( i = 0; i < markers.rows; i++ )
for( j = 0; j < markers.cols; j++ )
{
int index = markers.at<int>(i,j);
if( index == -1 )
wshed.at<Vec3b>(i,j) = Vec3b(255,255,255);
else if( index <= 0 || index > compCount )
wshed.at<Vec3b>(i,j) = Vec3b(0,0,0);
else
wshed.at<Vec3b>(i,j) = colorTab[index - 1];
}
wshed = wshed*0.5 + imgGray*0.5;
can any one explain the function of each line in the above code blocks?
Instead of painting each region by random colour is it possible to segment individual region in this code? here "index" variable represent the number of regions segmented in the image. for each index value (region) a particular colon is painted by the second code block. how can i segment each block can you have any idea sir?
But @StevenPuttemans i think this method will create 1 in all the "index" no of regions. Consider i have 14 regions in which some are sharing common boundary. When i set 1 for regions denoted by index variable the regions which are sharing common boundary will merge and produce 1 in the mask.
Got it Thanks