AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

Get only red and black

The forum is to discuss topics related to different areas of image processing and computer vision.

Get only red and black

Postby gustavooka » Tue Apr 30, 2019 7:48 pm

Hi all,

I am trying to improve my ocr algorithm and to do that I need to pre processing the image with AForge. I would like to know a sequence filters to "get only the red and black text". I tried a lot of filter but no success with any.
Attachments
modelo_19.png
modelo_19.png (221.4 KiB) Viewed 1488 times
modelo_18.png
modelo_18.png (221.83 KiB) Viewed 1488 times
modelo_17.png
modelo_17.png (222.32 KiB) Viewed 1488 times
gustavooka
 
Posts: 4
Joined: Tue Apr 30, 2019 7:45 pm

Re: Get only red and black

Postby bigbomber » Tue Apr 30, 2019 11:28 pm

easy to do
Absolute Black means the R & G & B value are 0.
but in a photo they never reach to 0, but have a very low value like 10 or 20.

I recommend you read the photo pixel by pixel and check if the pixels have low value for RGB or not. you can define a range like 0~50 to check too.

Also it is possible with Aforge.net libraries.
bigbomber
 
Posts: 5
Joined: Tue Apr 30, 2019 8:30 pm

Re: Get only red and black

Postby gustavooka » Wed May 01, 2019 2:03 am

Thanks for the response. Which way do you think that I can get the best performance of ocr (I want to read only black/grey and red letters)?
gustavooka
 
Posts: 4
Joined: Tue Apr 30, 2019 7:45 pm

Re: Get only red and black

Postby bigbomber » Wed May 01, 2019 6:54 am

gustavooka wrote:Thanks for the response. Which way do you think that I can get the best performance of ocr (I want to read only black/grey and red letters)?

i'm not a professional programmer.
but you can read letters with a special color by pixel to pixel reading method. it is easy to do.
but if your images have huge size, the code can get slow. you can try to check it.
bigbomber
 
Posts: 5
Joined: Tue Apr 30, 2019 8:30 pm

Re: Get only red and black

Postby andrew.kirillov » Wed May 01, 2019 7:57 am

Hello,

Check pixel filtering by color. You can set a range for black-ish pixels and then fill everything out of that range with white color, for example.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3446
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Get only red and black

Postby gustavooka » Wed May 01, 2019 1:57 pm

andrew.kirillov wrote:Hello,

Check pixel filtering by color. You can set a range for black-ish pixels and then fill everything out of that range with white color, for example.


Thanks Andrew, but I tried with all of the filters and the best result that I had is with Euclidean filter but I am having problem with the first line of the document "VALIDA EM TODO TERRITORIO NACIONAL" .
gustavooka
 
Posts: 4
Joined: Tue Apr 30, 2019 7:45 pm

Re: Get only red and black

Postby andrew.kirillov » Wed May 01, 2019 2:36 pm

If you always have same type/structure of documents, then you know roughly position of the first line, which has slightly different color. In this case you may apply different filter (or same filter with different settings) to that rectangle. Later you can combine both results.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3446
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Get only red and black

Postby gustavooka » Wed May 01, 2019 2:41 pm

andrew.kirillov wrote:If you always have same type/structure of documents, then you know roughly position of the first line, which has slightly different color. In this case you may apply different filter (or same filter with different settings) to that rectangle. Later you can combine both results.


Hi Andrew,

Thanks, but It's not the same image. The user capture those images (I attached two images to clarify).
Attachments
ImagemVerso.jpg
ImagemVerso.jpg (88.4 KiB) Viewed 1470 times
gustavooka
 
Posts: 4
Joined: Tue Apr 30, 2019 7:45 pm




Return to Image Processing and Computer Vision