How to make texts in images sharper using PIL? - opencv

I was working with PIL, OpenCV and OCR readers to read texts from Images. The biggest problem I faced is when it comes to Image processing to make texts sharp enough for easier/accurate extraction by the OCR reader.
For that, I thought of increasing the contrast/brightness and do a histogram equlization using PIL but that didn't help the cause either.
So, what would you suggest to do to make the texts appear sharper for better text extraction?

PIL has sharpen and edge enhancing filters. Is this what you want? An example image showing what you are dealing with would be helpful.
Your image has an uneven background color which may be causing problems. Try looking at this solution to create a nice leveled b&w image.
But the black collar is also going to cause problems and you should look at ways of cropping it out.
That said, I get reasonable improvements with a simple PIL SHARPEN filter:
tesseract results after SHARPEN filter:
From what I've learned looking inside people, ^ I've decided human
beings are somewhere ` between a hurricane and an ice cube} in some
respects, permanently mysterious, but in others- with enough science
and careful probingeentirely ' scrutabler It would be as foolish to
think we have reached the limits of human knowledge as it is to 3
think we could ever know everything. There is still room enough to
get better, to ask questions of i even the dead, to learn from
knowing when our i simple certainties are wrong.
And results without filter:
From what I've learned lnnkmg wade maple} Fve deculed lunnuan wlng;.
el'. .y.w.r-a' isbetween a luurrlctuvr null llva laAll.' a. I ll
respects, permanently unyst:-rwntMl ln ms. re with enough scaena)
and turutul pmlulng l~m.rely scrutable. It would he as loallsla to
thank we have reached the llmlts of human knowledge as lt ls to think
we could ever know everything. There ls still room enough to get
better, to ask quesuons of ` even the dead, to learn from knowmg when
our simple certeindes are wrong.

Related

ImageJ nanotubes detection and extraction

I have an image of a layer of carbon nanotubes taken with an electronic microscope and I would like to extract the "shape" of every nanotube.
I think that ImageJ could be very helpful since it has already led me to encouraging results, but I am sure that they could be improved.
Here is the image I start with :
I have seen that there are many tools to detect for example cells, or to divide an image in two areas (with the trainable Weka segmentation tool for instance), but I did not find anything to "follow" a tube from the beginning to the end. Does such a tool exist ?
What would you advise me to do to clean the image ? So far, I have tried 'auto local threshold' (loss of information), 'Remove outliers', 'analyse particles' (to remove the too-little-to-be-tubes-particles), and some skeleton tools + OrientationJ to extract information.
Thank you very much for your help !
EDIT : the "Tubeness" plugin was very helpful Tubeness documentation

tesseract OCR not 100% accurate

I need to scan a handwritten font. I am using tesseract OCR v3.02 for that. I have trained my OCR using box files and adding dictionary words as well but still I am not able to get 100% accuracy.
I am trying to scan the following image
So far the text file i am obtaining is like this:
We each took baths before bed. Bigfoot was so large that he had to use the bathtub more like a sink trying to clean
up his best. he left a pool of water around the usa It was a mess and I mopped it and removed all of the fur
left behind before taking a bath of my Own. I have to admit it was cguite disgusting. “It”s cguite simple.” Me
assured her. “Mere, I”ll show you.”Iimmy‘s was the favorite burger joint among us kids. Sreat burgers. and
there were video games and pinball machines. Jimmy”s has been around since the fift"es. all our parents used to
go there when they were young. “‘Mot exactly.""Another blanket. Ben. please."“I really hope so. because I feel so
Any help to improve the the OCR?

error detection on food packaging -using Open Cv

I am trying to determine when a food packaging have error or not error. Example
the logo " McDonald's " have error misprints or not, as the wrong label, wrong color..( i can not post picture )
What should I do, please help me!!
It's not a trivial task by any stretch of the imagination. Two images of the same identical object will always be different according to lightning conditions, perspective, shooting angle, etc.
Basically you need to:
1. Process the 2 images into "digested" data - dominant color, shapes, etcw
2. Design and run your own similarity algorithm between the 2 objects
You may want to look at Feature detectors in OpenCV: Surf, SIFT, etc.
Along a result I just found your question, so I think I come too late.
If not I think your problem car easily be resolved, it exists since years and is called Sikuli .
While it's for testing purposes, I have been using it in the same way as you need : compare a reference and a production image. Based on OpenCV it does it very well.

Edge detection to identify artist style?

I just wondered if anyone has every tried to use edge detection in regards to using it as a feature on its own for artist identification?
I know often most edge detection methods are used to then perform object detection with a database of objects, but cannot find whether or not edge detection can in isolation act as a feature!?
Any ideas?
Thanks
It takes a little bit more than basic edge detection, and having something better than just a photograph can make a big difference. Check out http://infolab.stanford.edu/~wangz/project/imsearch/ART/SP08/sp_vangogh.pdf
Yes, there's been some work on that (at L2CRMF that I know of, but others also).
Edge detection per se is not enough, though; you use it as a preliminary stage to identify features such as brush strokes, stroke vicinity, arcing, direction, average stroke length.
While talking shop, I was led to believe that this sort of analysis was a thankless task and much prone to errors; one of the many fields where human perception canniness still far outweighed automated processing. On the other hand this was back in 2003-2004, and things may have improved.
I have been able to find this reference, as well as this other which looks more promising.
Of historical interest only, Pliny (Naturalis Historia, XXXV.88, 81) reports of how Protogenes recognized a visitor to be the great painter Apelles from a line he had drawn, as it was so thin and perfect that such an absolute masterpiece could tally with no one else:
Ferunt Protogenem protinus, cum contemplatus esset subtilitatem,
dixisse Apellem venisse; adfirmavit enim tam absolutum opus non cadere
in alium

upper bound - display

This is an idea I got in to my mind,
All the display devices(screens which have pixels etc...) have an upper bound for the amount of various images they can generate.
as an example 1024*728 - 32 bit pixel display can only show (2^32)^(1024*768) etc... number of identical frames without duplicating any scene(view).
funny thing is, It's like we could pre generate all the films all the windows we have ever seen in our lives through screens etc...
the question here is can anybody use this abstract idea to create something useful? :D
You're talking of a number about
(2^32)^(1024*768) ~~ ((2^4)^8)^(10^6) ~~ 10^8^(10^6) ~ 10^8000000.
The number of atoms in universe is about
10^80 // http://en.wikipedia.org/wiki/Observable_universe#Matter_content
I think that there is no way we could pre-generate all the screens in our life.
Let me formulate another question. From a number this big, what can we do to reduce it? How to aggregate similar pictures in order to reduce the complexity?
Another nice question is: what kind of data structure we need to store all this information? Suppose we reduce the number of similar images to 10^10. What kind of structure can handle so many different kinds of pictures in an efficient way?
So given some extra information about the scenes you could generate you might be able to pull apart the scenes that no-one has ever seen.
So if you could take all the pictures out on the internet and the statistics about what was popular or viewed a lot then compute your all possible screens you could pull apart that was not viewed much.
With some basic rules about complexity of the image you might be able to come up with images that have not been seen before. Think 80% flesh tones might produce something coupled with a variance to show range might render people naked. :-)
Of course the computation of such an idea is vastly outside our potential. 2^32^(1024*768) is in the superexponential range which is outside the bounds of reality. I tried to compute it in ruby, and it just died. It would have been fun if it had actually worked. :-)

Resources