
... (in vertical direction)
A `cv::Mat` binarized image.
Thanks
I tried like following,
`img` is given image in this question.
bitwise_not(img, img_inv);
int totalrows = img_inv.rows;
int totalcols = img_inv.cols;
int hist[totalrows];
int blackspacecount = 0;
bool isbackground = true;
for(int i=0; i 0)
{
if(isbackground == true)
{
blackspacecount++;
isbackground = false;
}
}
else
{
isbackground = true;
}
}
int blackspaces[blackspacecount][2];
int p = 0;
for(int i=1; i 0 && hist[i-1] == 0)
{
blackspaces[p][0] = i; // Begin
}
if ( hist[i] == 0 && hist[i-1] > 0)
{
blackspaces[p][1] = i-1; // End
p++;
}
}
↧