+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Newbie
    Join Date
    Oct 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Preparing a photo for the OCR

    I want to make grey pixel near to black pixel to be darker. And grey pixel near white pixel become lighter. I also want to make green and red pixel become white. How can I do? Which technique would you prefer? I've tried for weeks but I cannot find an idea that depends upon near pixel and levels and color.

    imageshack.us/a/img35/6168/immagine1vkq.jpg

    imageshack.us/a/img811/6304/imgwqf.png
    Attached Thumbnails Attached Thumbnails Preparing a photo for the OCR-immagine-1.jpg  


  2. #2
    Banned
    Join Date
    Dec 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Preparing a photo for the OCR

    I think stamp tool is the best solution for your problem.

  3. #3
    Photography Section Moderator
    Join Date
    Oct 2012
    Posts
    3,172
    Thanks
    47
    Thanked 327 Times in 317 Posts

    Re: Preparing a photo for the OCR

    "I think stamp tool is the best solution for your problem." - I think one would get extremely tired after using the stamp tool at the pixel level on a page or two of text. . You need something more automated.

    Getting rid of the color is easy. The easiest approach is to simply desaturate the image, or, if the text is always black or gray, just select pixels with saturation more than 5 or 10% and turn them all white. You can do this using plugins such as Asiva "Select" or an old one called HSB/HSL (that still works fine in CS6) followed by some fiddling around with the S and L channels.

    The second half of your question is a lot more involved. Take a look at the image processing operators, "open" and "close", e.g.,
    http://en.wikipedia.org/wiki/Opening_%28morphology%29
    http://en.wikipedia.org/wiki/Closing_%28morphology%29

    If you are technically / mathematically inclined, for lots good background info on them, go to:
    http://en.wikipedia.org/wiki/Mathematical_morphology

    Such operators (including "erode" and "dilate"), are commonly used for tasks like this. Unfortunately, I don't know of any good implementations of them as photoshop plugins or easy image editors. They are certainly available in Matlab and, if memory serves me, Mathematica and also J-image (from NIH). The latter might be the most useful to you.

    The only implementation of erode and dilate (no "close" and "open") that I know about in an easy-to-use image editing program is in Photoscape 3.6, but I don't consider their implementation very good / flexible. If anyone knows of good implementations of these operators somewhere else, I would love to hear about it.

    Cheers,

    Tom M
    Last edited by Tom Mann; 12-26-2012 at 02:51 AM.

  4. #4
    Photography Section Moderator
    Join Date
    Oct 2012
    Posts
    3,172
    Thanks
    47
    Thanked 327 Times in 317 Posts

    Re: Preparing a photo for the OCR

    Here are two examples. The first image is a small crop of your longer document for comparison purposes.

    The 2nd image is the same image after using ASIVA Select (mentioned above) twice. First, to change the color of the lighter colored random pixels to white, then, on a 2nd pass to change the color of the darker (but colored) pixels to black.

    I'm not at my work computer, so I didn't have access to any of the morphological image transformations mentioned in my earlier post, but I did have Medhi's Flat Median plugin on this computer. It is not as good as the correct mathematical operations, but it does help a bit: You can see that some of the white pixels in the letters are filled in by using it.

    HTH,

    Tom M
    Attached Thumbnails Attached Thumbnails Preparing a photo for the OCR-imgwqf-01_ps02c_cropped-stacked_3_hi-01.jpg  


 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Powered by vBulletin® Version 4.1.9
Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.
Content Relevant URLs by vBSEO 3.6.0
Copyright 2011 Photoshop Gurus Forum. All rights reserved.
All times are GMT -5. The time now is 09:58 PM.