1 | initial version |
Take a binary image and 'colour' in the black sections. Use floodFill
by looping over the whole image and flood filling every black section. In the end, you are left with a white outline with a value of 1, and each distinct section filled with a value larger than 1 (a unique ID).
int section_count = 0;
int fill_colour = 2;
for(int j = 0; j < flt_canny.rows; j++)
{
for(int i = 0; i < flt_canny.cols; i++)
{
float colour = flt_canny.at<float>(j, i);
if(colour == 0)
{
floodFill(flt_canny, Point(i, j), Scalar(fill_colour));
section_count++;
fill_colour++;
}
}
}
2 | No.2 Revision |
Take a binary image and 'colour' in the black sections. Use sections: use floodFill
by looping over the whole image and flood filling every black section. In the end, you are left with a white outline with a value of 1, and each distinct section filled with a value larger than 1 (a unique ID).
int section_count = 0;
int fill_colour = 2;
for(int j = 0; j < flt_canny.rows; j++)
{
for(int i = 0; i < flt_canny.cols; i++)
{
float colour = flt_canny.at<float>(j, i);
if(colour == 0)
{
floodFill(flt_canny, Point(i, j), Scalar(fill_colour));
section_count++;
fill_colour++;
}
}
}
3 | No.3 Revision |
Take a binary image and 'colour' in the black sections: sections (regions): use floodFill
by looping over the whole image and flood filling every black section. In the end, you are left with a white outline with a value of 1, and each distinct section filled with a value larger than 1 (a unique ID).
int section_count = 0;
int fill_colour = 2;
for(int j = 0; j < flt_canny.rows; j++)
{
for(int i = 0; i < flt_canny.cols; i++)
{
float colour = flt_canny.at<float>(j, i);
if(colour == 0)
{
floodFill(flt_canny, Point(i, j), Scalar(fill_colour));
section_count++;
fill_colour++;
}
}
}
4 | No.4 Revision |
Take a binary image and 'colour' in the black sections (regions): use floodFill
by looping over the whole image and flood filling every black section. pixel. In the end, you are left with a white outline with a value of 1, and each distinct section filled with a value larger than 1 (a unique ID).
int section_count = 0;
int fill_colour = 2;
for(int j = 0; j < flt_canny.rows; j++)
{
for(int i = 0; i < flt_canny.cols; i++)
{
float colour = flt_canny.at<float>(j, i);
if(colour == 0)
{
floodFill(flt_canny, Point(i, j), Scalar(fill_colour));
section_count++;
fill_colour++;
}
}
}
5 | No.5 Revision |
Take One way to go about it is to take a binary image and 'colour' in the black sections (regions): use floodFill
by looping over the whole image and flood filling every black pixel. In the end, you are left with a white outline with a value of 1, and each distinct section filled with a value larger than 1 (a unique ID).
int section_count = 0;
int fill_colour = 2;
for(int j = 0; j < flt_canny.rows; j++)
{
for(int i = 0; i < flt_canny.cols; i++)
{
float colour = flt_canny.at<float>(j, i);
if(colour == 0)
{
floodFill(flt_canny, Point(i, j), Scalar(fill_colour));
section_count++;
fill_colour++;
}
}
}
6 | No.6 Revision |
One way to go about it is to take a binary image and 'colour' in the black sections (regions): use floodFill
by looping over the whole image and flood filling every black pixel. In the end, you are left with a white outline with a value of 1, and each distinct section filled with a value larger than 1 (a unique ID).ID). It doesn't have to use floats, I just like floats. :)
int section_count = 0;
int fill_colour = 2;
for(int j = 0; j < flt_canny.rows; j++)
{
for(int i = 0; i < flt_canny.cols; i++)
{
float colour = flt_canny.at<float>(j, i);
if(colour == 0)
{
floodFill(flt_canny, Point(i, j), Scalar(fill_colour));
section_count++;
fill_colour++;
}
}
}
7 | No.7 Revision |
One way to go about it is to take a binary image (pixels with value 0.0 or 1.0) and 'colour' in the black sections (regions): use floodFill
by looping over the whole image and flood filling every black pixel. In the end, you are left with a white outline with a value of 1, and each distinct section filled with a value larger than 1 (a unique ID). It doesn't have to use floats, I just like floats. :)
int section_count = 0;
int fill_colour = 2;
for(int j = 0; j < flt_canny.rows; j++)
{
for(int i = 0; i < flt_canny.cols; i++)
{
float colour = flt_canny.at<float>(j, i);
if(colour == 0)
{
floodFill(flt_canny, Point(i, j), Scalar(fill_colour));
section_count++;
fill_colour++;
}
}
}
8 | No.8 Revision |
One way to go about it is to take a binary image (pixels with value 0.0 or 1.0) and 'colour' in the black sections (regions): use floodFill
by looping over the whole image and flood filling every black pixel. In the end, you are left with a white outline with a value of 1, and each distinct section filled with a value larger than 1 (a unique ID). It doesn't have to use floats, I just like floats. :)
int section_count = 0;
int fill_colour = 2;
for(int j = 0; j < flt_canny.rows; j++)
{
for(int i = 0; i < flt_canny.cols; i++)
{
float colour = flt_canny.at<float>(j, i);
if(colour == 0)
{
floodFill(flt_canny, Point(i, j), Scalar(fill_colour));
section_count++;
fill_colour++;
}
}
}
// Get number of pixels per section colour
map<float, int> section_sizes;
for(int j = 0; j < flt_canny.rows; j++)
{
for(int i = 0; i < flt_canny.cols; i++)
{
float colour = flt_canny.at<float>(j, i);
if(colour != flt_white)
section_sizes[colour]++;
}
}
// No sections (the image was all white)
if(section_sizes.size() == 0)
continue;
9 | No.9 Revision |
One way to go about it is to take a binary image (pixels with value 0.0 or 1.0) and 'colour' in the black sections (regions): use floodFill
by looping over the whole image and flood filling every black pixel. In the end, you are left with a white outline with a value of 1, and each distinct section filled with a value larger than 1 (a unique ID). It doesn't have to use floats, I just like floats. :)
int section_count = 0;
int fill_colour = 2;
for(int j = 0; j < flt_canny.rows; j++)
{
for(int i = 0; i < flt_canny.cols; i++)
{
float colour = flt_canny.at<float>(j, i);
if(colour == 0)
{
floodFill(flt_canny, Point(i, j), Scalar(fill_colour));
section_count++;
fill_colour++;
}
}
}
// Get number of pixels per section colour
map<float, int> section_sizes;
for(int j = 0; j < flt_canny.rows; j++)
{
for(int i = 0; i < flt_canny.cols; i++)
{
float colour = flt_canny.at<float>(j, i);
if(colour != flt_white)
section_sizes[colour]++;
}
}
// No sections (the image was all white)
if(section_sizes.size() == 0)
continue;
10 | No.10 Revision |
One way to go about it is to take a binary image (pixels with value 0.0 or 1.0) and 'colour' in the black sections (regions): use floodFill
by looping over the whole image and flood filling every black pixel. In the end, you are left with a white outline with a value of 1, and each distinct section filled with a value larger than 1 (a unique ID). It doesn't have to use floats, I just like floats. :)
int section_count = 0;
int fill_colour = 2;
for(int j = 0; j < flt_canny.rows; j++)
{
for(int i = 0; i < flt_canny.cols; i++)
{
float colour = flt_canny.at<float>(j, i);
if(colour == 0)
{
floodFill(flt_canny, Point(i, j), Scalar(fill_colour));
section_count++;
fill_colour++;
}
}
}
// Get number of pixels per section colour
map<float, int> section_sizes;
for(int j = 0; j < flt_canny.rows; j++)
{
for(int i = 0; i < flt_canny.cols; i++)
{
float colour = flt_canny.at<float>(j, i);
if(colour != flt_white)
> 1)
section_sizes[colour]++;
}
}