locked
Image to Binary conversion, Pixel Sample scaling question RRS feed

  • Question

  • I am modifying a tutorial and writing a small program that imports a black and white image, (mainly bmp) and converts the image to binary.   I have a window set up with an image box, and a text field that is scrollable with word-wrap off.  My code works on a per pixel basis, but I would like to increase the scale of sampling to a 10px by 10px range, and get the predominant value to print out.

    for (int i = 0; i < img.Height; i++)
    {
        for (int j = 0; j < img.Width; j++)
        {
            if (img.GetPixel(j, i).A.ToString() == "255" && img.GetPixel(j,i).B.ToString() == "255" && img.GetPixel(j, i).G.ToString() == "255" && img.GetPixel(j, i).R.ToString() == "255")
            {
                texto = texto + "0";
            }
            else
            {
                texto = texto + "1";
            }
        }
        texto = texto + "\r\n";
    }

    My question is where to put the 10x range multiplyer and how to get the average?
    Saturday, January 26, 2008 5:49 AM

Answers

  • You can use the Image.GetThumbnailImage method to scale your image to the size you need before converting it to binary format. For more information, see GetThumbnailImage method.

    Thursday, January 31, 2008 7:32 AM