Tesseract not recognizing anything after image processing - image

This is the image before I processed it:
After processing, it looks like that:
I think that the second one is great, but it looks like I am very wrong. When I used tesseract on original image, it recognized some of the text. But when I do it on the second one (the black and white one) it does not recognize anything at all! Why is that? What am I doing wrong here?

I've tested a little with your images. I think the main problem is the poor image quality. Try images in higher resolution, that could work a lot better.
I assume you only want the item names? If yes, then delete the "Buy Now for:" and the coins + the according numbers also (just paint them black like the rest), that made it better for me!
Also play around with the different settings of Tesseract I had the best results with psm 1 and 6 I think.
Conclusion: Higher image quality (resolution) should work the best!

Related

Tesseract-OCR (3.02) recognition accuracy and speed

I have group of very small images (w:70-100 ; h:12-20), like the one below:
In those images nothing but nickname of group's member. I want to read the text from simple images, they all have one background, only nickames are different. So, what I've done with that image:
I am using code below to get text from second image:
tesseract::TessBaseAPI ocr;
ocr.Init(NULL, "eng");
PIX* pix = pixRead("D:\\image.png");
ocr.SetImage(pix);
std::string result = ocr.GetUTF8Text();
I have 2 problems with that:
The ocr.GetUTF8Text(); is working slow: 650-750ms. Image is small, why it works so long anyway?
From the image above I am getting result like: "iwillkillsm", "iwillkillsel" etc. That image is simple, and I believe tesseract gurus are able to recognize it with 100% accuracy.
What should I do with image/code or what should I read (and where) about tesseract-ocr (something about text speed and quality recognition) to solve those problems?
It may sound odd, but I've always had the best luck with tesseract when I increased the dimensions of the image. The image would look "worse" to me but tesseract went faster and had much better accuracy.
There is a limit to how big you can make the images before you start getting worse results however :) I think I remember shooting for 600px in the past. You'll have to play with it though.

How to identify JPG/PNGS that are mosty text? (Windows/Mac/Linux prgram to do this?)

Here's my problem: A folder of 20,000 images- many of them are photographs but lots of them are basically scans of book text. I want to delete those.
Sorting by size helps a little, but since the images are of different resolutions some of the text ones are in fact bigger than the photo ones.
I'm thinking if I can find a program that can sort by color depth that might work? However a simply 'Number of colors' sort might not work because many of the photos i want to keep are drawings/black and white
Any ideas?
I have access to windows, mac, linux
You could use a OCR Library for a Language of your choice. And if you get a String with more than 50 chars it's a textscan.
That's how I would try it.
Edit: 50 is just an example. You need to test what fits the best
Have you try to do something like Histogram analyse? Maybe it is not possible because of your black and white images, but they should have more different gray scales then that one with text. You could check which range of gray colors the images cover.

Enlarging image without affecting clarity

I need to enlarge the image downloaded without affecting its clarity.but when resized its clarity has gone.Can any one help?
Given the context, by clarity I assume you mean visual appearance. You want your upscaled image, again I believe you are dealing with upscaling and not downscaling (it is not specified in your problem), to look visually good. We actually can magically create detail, but probably not a perfect one. There are techniques for specifically working with pixelated images, hqx or http://research.microsoft.com/en-us/um/people/kopf/pixelart/paper/pixel.pdf for instance. Since that is not clear from your description either, I'm simply assuming you have images of any kind.
With these considerations, you have yet to describe what you tried. Let me guess you tried a nearest neighbor interpolation, so you get something like:
There are other common types of interpolation. Like bicubic, Lanczos or something more modern like ICBI or http://www.cs.huji.ac.il/~raananf/projects/lss_upscale/paper.pdf. Consider the first three of those, we get the respective results:
It may be a little hard to visualize the differences among these last three, but if you zoom into the actual images then you will be able to notice them. ICBI gives sharpest edges in this case.
Image resizing will always affect clarity, unless you downloaded a vector graphics image. See if the image has a vector graphics format, and if so, download that.
Failing that, you could try to see if larger image sizes are available, as generally shrinking hurts the image quality less than increasing.

How can I deblur an image in matlab?

I need to remove the blur this image:
Image source: http://www.flickr.com/photos/63036721#N02/5733034767/
Any Ideas?
Although previous answers are right when they say that you can't recover lost information, you could investigate a little and make a few guesses.
I downloaded your image in what seems to be the original size (75x75) and you can see here a zoomed segment (one little square = one pixel)
It seems a pretty linear grayscale! Let's verify it by plotting the intensities of the central row. In Mathematica:
ListLinePlot[First /# ImageData[i][[38]][[1 ;; 15]]]
So, it is effectively linear, starting at zero and ending at one.
So you may guess it was originally a B&W image, linearly blurred.
The easiest way to deblur that (not always giving good results, but enough in your case) is to binarize the image with a 0.5 threshold. Like this:
And this is a possible way. Just remember we are guessing a lot here!
HTH!
You cannot generally retrieve missing information.
If you know what it is an image of, in this case a Gaussian or Airy profile then it's probably an out of focus image of a point source - you can determine the characteristics of the point.
Another technique is to try and determine the character tics of the blurring - especially if you have many images form the same blurred system. Then iteratively create a possible source image, blur it by that convolution and compare it to the blurred image.
This is the general technique used to make radio astronomy source maps (images) and was used for the flawed Hubble Space Telescope images
When working with images one of the most common things is to use a convolution filter. There is a "sharpen" filter that does what it can to remove blur from an image. An example of a sharpen filter can be found here:
http://www.panoramafactory.com/sharpness/sharpness.html
Some programs like matlab make convolution really easy: conv2(A,B)
And most nice photo editing have the filters under some name or another (sharpen usually).
But keep in mind that filters can only do so much. In theory, the actual information has been lost by the blurring process and it is impossible to perfectly reconstruct the initial image (no matter what TV will lead you to believe).
In this case it seems like you have a very simple image with only black and white. Knowing this about your image you could always use a simple threshold. Set everything above a certain threshold to white, and everything below to black. Once again most photo editing software makes this really easy.
You cannot retrieve missing information, but under certain assumptions you can sharpen.
Try unsharp masking.

Image processing - one frame is washed out, other isn't. How to 'fix'?

I have the following 2 consequative, unaltered frames from a video:
For some reason the camera made the 2nd much 'washed out' than the first. I want to make the 2nd look more like the 1st.
In the video I'm trying to process, there are lots of cases like this, where the 'exposure' changes suddenly from one frame to the next. I am able to find this parts of the video by looking at the image histogram for each frame, and when 2 adjacent frames have histograms that are too far apart, it's where this has happened. I can find this sections of different exposure, but I'm stumped with how to fix it.
As a programmer I'm familar with ImageMagick and that's about it. Since I have lots of frames, some automated hand off approach to fix this is by far the best solution. I am also totally unskilled with graphics editing programmes.
I've tried changing the exposure in imagemagick (with -level 0,50% etc.), but that doesn't help.
What ImageMagick commands (or other FLOSS image editing tools) will make the 2nd image look more like the 1st?
As some people have pointed out in the comments, the problem is the colour balance. Changing the colour balance makes the 2 images more similar.

Resources