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 7748623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:49:58+00:00 2026-06-01T10:49:58+00:00

I’m using tesseract in my iPhone application. I tried several filters on my image

  • 0

I’m using tesseract in my iPhone application.

I tried several filters on my image for converting it to a grayscale image, however I’d like to have the result where a threshold is being set so that the only pixels which are inside the image are black or white.

I succeeded with using apples grayscale filter which gives the appropriate result. However it’s still a 16 bit image (correct me if I’m wrong). The filtering which I’m using at the moment is as follows:

- (UIImage *) grayishImage:(UIImage *)i {

    // Create a graphic context.
    UIGraphicsBeginImageContextWithOptions(i.size, YES, 1.0);
    CGRect imageRect = CGRectMake(0, 0, i.size.width, i.size.height);
// Draw the image with the luminosity blend mode.
[i drawInRect:imageRect blendMode:kCGBlendModeLuminosity alpha:1.0];
    // Get the resulting image.
    UIImage *filteredImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return filteredImage;
}

Can anyone supply me with the filter to get pure black and white pixels and not grayscale images?

  • 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-01T10:50:00+00:00Added an answer on June 1, 2026 at 10:50 am

    Probably the fastest way to do this would be to use OpenGL ES 2.0 shaders to apply the threshold to your image. My GPUImage framework encapsulates this so that you don’t need to worry about the more technical aspects behind the scenes.

    Using GPUImage, you could obtain a thresholded version of your UIImage using a GPUImageLuminanceThresholdFilter and code like the following:

    GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:inputImage];
    GPUImageLuminanceThresholdFilter *stillImageFilter = [[GPUImageLuminanceThresholdFilter alloc] init];
    stillImageFilter.threshold = 0.5;
    [stillImageSource addTarget:stillImageFilter];
    [stillImageFilter useNextFrameForImageCapture];
    [stillImageSource processImage];
    
    UIImage *imageWithAppliedThreshold = [stillImageFilter imageFromCurrentFramebuffer];
    

    You can just pass your color image into this, because this automatically extracts the luminance from each pixel and applies the threshold to that. Any pixel above the threshold goes to white, and any one below that is black. You can adjust the threshold to meet your particular conditions.

    However, an even better choice for something you’re going to pass into Tesseract would be my GPUImageAdaptiveThresholdFilter, which can be used in the same way as the GPUImageLuminanceThresholdFilter, only without a threshold value. The adaptive thresholding does a thresholding operation based on a 9 pixel region around the current pixel, adjusting for local lighting conditions. This is specifically designed to help with OCR applications, so it might be the way to go here.

    Examples images from both types of filters can be found in this answer.

    Note that the roundtrip through UIImage is slower than handling raw data, so these filters are much faster when acting on direct video or movie sources, and can run in realtime for those inputs. I also have a raw pixel data output, which might be faster for use with Tesseract.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have thousands of HTML files to process using Groovy/Java and I need to
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the

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.