Closed rajasajidmanzoor closed 10 years ago
I got reasonable results after I (manually) cropped the image so the border isn't included and then binarized the image (using BinarizeOtsuAdaptiveThreshold, with params img.Width / 5
, img.Height / 5
, 10, 10, 0.1 as previously mentioned in #71).
You will of course need to find a way to crop the image automatically maybe either doing some edge detection or page analysis.
hmm. thanks. Can you please share a code example for BinarizeOtsuAdaptiveThreshold and also please tell me where should i use BinarizeOtsuAdaptiveThreshold..
Thanks
Something like this:
using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default)) {
using (var img = Pix.LoadFromFile(testImagePath)) {
using (var binarizedImg = img.BinarizeOtsuAdaptiveThreshold(img.Width / 5, img.Height / 5, 10, 10, 0.1F)) {
binarizedImg.Save("Binarized-test.png", ImageFormat.Png);
using (var page = engine.Process(binarizedImg)) {
var text = page.GetText();
// whatever
}
}
}
}
Where/How to use this is really going to depend on how you've written your application and what other processing you plan on doing.
Note that the testImagePath
must be a path to a 8 BPP (bit's per pixel) image. Binarization WILL fail if it's anything else.
ok. How can i check that image in 8 bits per pixel image in c# and if it is not a 8 BPP image than how can i make it 8BPP
thanks
Your after the Depth property which will need to equal 8 in this case. As for converting a 32-bit image (or other source) you'll probably want to use a Quantization method unfortunately I haven't wrapped these methods from Leptonica at this time. I've added issue #75 however can't say when I'll get to this. Another option may be to capture the images as 8-bit images if possible.
hello Can you please describe what is Quantization method. I tried to convert an image to Bit using following method. http://codingresolved.com/discussion/2185/save-png-image-as-8bit-format-in-c and then applied binarization as you told me above. but it is not reading text from image. the image that i have used is (before converting to 32 bit see below image) before converting to 8 bit it only reads last line.
See below image after conversion to 8 bit. Not a single word has been read after converting to 8 bit.
Did you also crop it, this is the image I ended up processing that worked:
Hello Please confirm how did you achieved this result. i performed following trick to get the second image http://codingresolved.com/discussion/2185/save-png-image-as-8bit-format-in-c
I just opened it in my favorite picture editor (Paint.Net in this case), cropped the image and saved it as a png file with 256 colours (8 bpp) and then fed that to the previously mentioned routine.
hmm. Ok thanks But if possible can you please share a code example for pixOctreeColorQuant so that i get a start. I know that i am disturbing you and taking a lot of your time but i don't have any other way to sort out. I will be thankful to you if you help me.
OK, given you time limits here's what I would do:
If step 2 doesn't come up with any results you could try a fallback of just cropping the edges and checking the results however this is really unreliable but might be better than nothing.
ok. but there where is sample. Are you talking about the samples included in Wrapper..
Yes, specifically the console one.
On Wed, Feb 12, 2014 at 8:44 PM, sajiddesigner notifications@github.comwrote:
ok. but there where is sample. Are you talking about the samples included in Wrapper..
Reply to this email directly or view it on GitHubhttps://github.com/charlesw/tesseract/issues/74#issuecomment-34852981 .
and also please confirm that which file format is best for optimum results in tesseract. JPG, PNG, TIFF or Gif.
Hello. I am trying to capture images via webcam and then read it using OCR but OCR is not reading them. I have also bought an HD 1080p anti flare and anti noise web cam but sill it is not reading Text and number. I am trying to read from following images. ![Uploading 635274052466609107.pn
g . . .]()
But it is not reading all images. I also tried using Grey scale images but still issue persists. Please tell me how can i read these images or also suggest me any image processing techniques if needed..
Sajid