Hi:
I have developed code to scan different sections of an image on background panel, after Otsu Thresholding has been applied to the image, and add up pixel values. After this it should evaluate whether the values are above or below a set threshold value. If any of those sections are above the threshold value a rectangle should be drawn around the sections.
The code below shows the array population and scan and a poor attempt at drawing on the image.
Bitmap myImage;
myImage = (Bitmap)Image.FromFile(openFileDialog1.FileName);
panel1.BackgroundImage = myImage;
float[] resultArray = new float[myImage.Height];
for (int i = 0; i > 26 && i < 39; i++)
{
float value1 = 0;
for (int j = 0; j > 22 && j < 35; j++)
{
value1 += myImage.GetPixel(j, i).GetBrightness();
}
resultArray[i] = value1;
if (value1 > 0)
{
Pen pen = new Pen(Color.Red, 2);
Graphics g = panel1.CreateGraphics();
g.DrawRectangle(pen, 10, 10, 50, 50);
}
This is just one array for the first section. I guess the best thing to do would be to create a function for the drawing part and just pass it the values of the arrays from a switch, case1, case2, etc. But my main concern is getting help to draw around the section detailed above. I have set the if condition to value > 0 for now just to be sure and test it works.
Thank you.