Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8565667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:28:45+00:00 2026-06-11T17:28:45+00:00

Scope: I am trying to Binarize ( convert to only two colors ) the

  • 0

Scope:

I am trying to “Binarize” ( convert to only two colors ) the images that can be found here. The binarized output must follow this logic : Characters will be painted as a “Color X” and everything else will be painted as “Color Y”.

Ideally X is White and Y is black( but X and Y does not really matter).

Observations:

After some observations, i figured out that the characters are either “Yellow tones”, “White Tones” or “Black Tones”.
Using the code Bellow, i should be able to recognize and convert all those “tones” (Color channels thresholding) to one color, and whole rest, into another color.

Code Sample:

// My Own Web Requests Class. You can use C# 
WebRequests wr = new WebRequests();  

Native One
Bitmap bmp;
string url = "http://www.fazenda.rj.gov.br/projetoCPS/codigoImagem";

bmp = wr.GetBitmap(url);
bmp.Save(@"captcha.bmp");

for (int i = 0; i < bmp.Width; i++)
{
    for (int j = 0; j < bmp.Height; j++)
    {
        Color pixel = bmp.GetPixel(i, j);
        byte R, G, B;

        // Fetching RGB Values
        R = pixel.R;
        G = pixel.G;
        B = pixel.B;

        // Converting Black tones 
        if ((R < Color.Black.R + 110)
            && (G < Color.Black.G + 110)
            && (B < Color.Black.B + 110))
        {
            bmp.SetPixel(i, j, Color.Orange);
            continue;
        }

        // Converting Yellow tones
        if ((R > Color.Yellow.R - 110)
                && (G > Color.Yellow.G - 110)
                && (B < Color.Yellow.B + 110))
        {
            bmp.SetPixel(i, j, Color.Orange);
            continue;
        }

        // Converting White tones
        if ((R > Color.White.R - 110)
            && (G > Color.White.G - 110)
            && (B > Color.White.B - 110))
        {
            bmp.SetPixel(i, j, Color.Orange);
            continue;
        }

        bmp.SetPixel(i, j, Color.Orchid);
    }
}

bmp.Save(@"FilteredCaptcha.bmp");

Problem:

After running this code, the saved output (Bitmap) actually have more than the two colors i defined in code (which are “Orange” for characters and “Orchid” for everything else, in this sample).

Once i “Zoom In” using Windows Explorer / Gimp / ImageProcessingLab , there are “tones” of orange and “tones” of orchid.

What am i missing here ? Why aren’t the outputs binarized if the only uses “two” colors, instead of “tones” to Set the pixel Colors ?

I uploaded some images to make your inspection job easier.

Input Bitmap:

Input Bitmap

Output Bitmap:

Output Bitmap

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:28:46+00:00Added an answer on June 11, 2026 at 5:28 pm

    Change where you save it to:

    bmp.Save(@"c:\temp\FilteredCaptcha.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
    

    Your code is clearly only setting two colours so the only possibility I see is that the source image is a JPG, and this format is being preseved when you save it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a named scope that will order my 'Products' class based
I'm trying to create a simple scope that sphinx will index (Ruby on Rails).
I am trying to create a macro that takes a scope as a parameter.
I'm trying to make a timer that measures the execution time of a scope.
I'm trying to figure out how to make a scope that will return random
Here is the scope. I am trying to create a base class you will
I'm trying to create a regexp that can match this: argument ::= define_scope [';'
I have been trying to implement the new scope features that were recently added
Possible Duplicate: Can a local variable's memory be accessed outside its scope? I'm trying
Like others before me I'm struggling with scope in Javascript. (That and trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.