Side fill opencv.I want to fill sides of a binary image.

asked 2014-02-06 08:49:29 -0600

Shubham gravatar image

updated 2018-01-31 15:19:36 -0600

I have a binary image.image description I want to fill its sides. like this- image description for it I wrote a code in opencv (here I am just mentioning code for that particular section only)

for (int j =dst.cols; j>=0; j--) {
for (int i =dst.rows; i>=0; i--) {
    if (dst.at<char>(i,j) == 0){
        dst.at<char>(i,j)=255;
    }  
    if (dst.at<char>(i,j)>0){
        for (int k =i; k>=0; k--) {
        dst.at<char>(k,j)=0;
      }
    }   


}
}

//But I dont get the result.It shows "Segmentation fault(core dumped)" and sometimes it shows but it shows whole image black. Please help.

edit retag flag offensive close merge delete

Comments

j=dst.cols is not a valid index. j=dst.cols-1 is. (same for i)

berak gravatar imageberak ( 2014-02-06 09:04:17 -0600 )edit

fine. but it's again showing completely white image? Is there a problem in Logic?

Shubham gravatar imageShubham ( 2014-02-06 09:25:42 -0600 )edit

wait, that was about the segfault only.

sorry, but i neither understand, what your code does, nor what you're trying to achieve.

berak gravatar imageberak ( 2014-02-06 09:43:41 -0600 )edit