Reply to thread

I have a camera that is returning a one dimensional array of bytes.  the 1st two indexes of the array make up 1st pixel in the image the last two indexes in the array make up the last  pixel in the image.


I only want to work on a sub two dimensional array   of the image : a  rectangle


               endY , endX ,  rect.Y , rect.X 


have the  values of the  sub image I want to work on.I times this by 2 because  two indexes of the array make up one pixel.


I know that  rect. X * rect.Y will give me the index in the one dimensional array I need to start at.


and that      end.Y * end.X is where I need to stop at.


global_X and global_Y has the width and the Height of the two dimensional image.


Global_X = width and Global _Y = Height;



but I cannot seem to get how I should set up my  nested for loop.



so I have this :



 Rectangle rect = videoSourcePlayer.Imagebox(startX, startY, diffX, diffY);


                endY = (rect.Y + rect.Height) * 2;

                endX = (rect.X + rect.Width) * 2;


                rect.Y = rect.Y * 2;

                rect.X = rect.X * 2;


int addingValue = 0;


int value2 =0;


double l =0;

                for (int y = rect.X * rect.Y; y <= endY; y = y + 2)

                {

                    for (int x = rect.X * rect.Y; x <= global_X *rect.Y; x = x + 2)

                    {


                        int value = ((transfer.bits[x] << 8) + transfer.bits[x + 1]);

                        value2 = (value >> 4);

                         addingValue += value2;


                        tempD = data[y, x];

                        answer = answer + tempD;

                        l++;

                    }

                }


double returnValue =  (double) addingValue /l;


return returnValue;

            }


Continue reading...


Back
Top