Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Nested if-else conditions

Hello All...I know this is very small and stupid doubt but I don't know why I'm getting stuck here. I am using nested if-else loops inside "for" loop in my code but it at all not going inside this "for" loop. I checked it by putting Log.d statements inside each condition but none of then are getting printed. My block of code is as follows:

         Mat fin = new Mat (gray.rows(), gray.cols(), CvType.CV_8UC3);
         for (int ii=0;ii<rows;ii++)
        {
            for (int j=0;j<cols;j++)
            {
                if ( gray.get(ii, j)[0] < 32)
                {
                    fin.get(ii, j)[0] = 1;
                }
                else if (gray.get(ii, j)[0]>31 && gray.get(ii, j)[0] < 64)
                {
                    fin.get(ii, j)[0] = 2;
                }
                else if (gray.get(ii, j)[0] > 63 && gray.get(ii, j)[0] < 96)
                {
                    fin.get(ii, j)[0] = 3;
                }
                else if (gray.get(ii, j)[0] > 95 && gray.get(ii, j)[0] < 128)
                {
                    fin.get(ii, j)[0] = 4;
                }
                else if (gray.get(ii, j)[0] > 127 && gray.get(ii, j)[0] < 160)
                {
                    fin.get(ii, j)[0] = 5;
                }
                else if (gray.get(ii, j)[0] > 159 && gray.get(ii, j)[0] < 192)
                {
                    fin.get(ii, j)[0] = 6;
                }
                else if (gray.get(ii, j)[0] > 191 && gray.get(ii, j)[0] < 224)
                {
                    fin.get(ii, j)[0] = 7;
                }
                else if (gray.get(ii, j)[0] > 223 && gray.get(ii, j)[0] < 256)
                {
                    fin.get(ii, j)[0] = 8;
                }
                     }
            }

Please help!! Thanks in advance!!