Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

how to know there is a transition in a string of binary numbers

hi, if i have a string of binary number scan from a binary image from this code

     for( int y=0; y< frame_gray.rows; y+=10){
    for (int x=0;x< frame_gray.cols;x+=1){

        if (frame_gray.at<uchar>(y,x)==0)
        {  cout << "0 binary=" << endl;}

        else
        {  cout << "1 binary=" << endl;width++;}
        //waitKey(0);

    }

    cout << "width=" << width << endl;
    width=0;
    cout << "new pixel line" << endl;
}

as example output is 0000000111111000000, how can i write a code to tell me there is two times of value transition 0-->1 and 1--->0? or

00001111100000111100000 there are 4 times of transition happened.

thanks