c++ - Threshoding image between certain range -


how threshold image between range? have done doesn't work.

for (int i=0;i<s.size().height;i++) {     for(int j=0;j<s.size().width;j++)     {         int k=int (s.at<uchar>(j,i));         if (k>6 &&  k<10)             k=255;         else k=0;             s.at<uchar>(j,i)=k;     } } 

you uchar value, , convert integer. try :

    uchar k= s.at<uchar>(j,i);     if (k>6 &&  k<10) {         k=255;      }else {         k=0;      }      s.at<uchar>(j,i)=k; 

i think may work.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -