i've been trying to open a .jpg image using
im = Image.open('file.jpg').
my problem is that for some reason the "im" is not an RGB image, i.e the channels are not R,G,B. this also cause the im.convert('L') (rgb2gray) give a very bad result.
channel 0 image,
attemped gray sacale.
Im using: Python 2.7.12 |Anaconda 4.1.1 (64-bit)
I would very much appreciate any help figuring this out.
edit:
it seems the problem is that the matplotlib color map isn't set right. does anyone know why? and how to fix?
You can find current mode in im.mode and do convert with im.convert('RGB').
Related
I am trying to convert a high resolution image (30in width x 60in height) to a pdf file in MATLAB. I tried print, exportgraphics, and couple scripts online but I keep getting low quality output. I also tried setting the resolution to 300dpi but it didnt work. Please if you have any suggestions, share with me and I will test. Many thanks!
Image file used (renamed to map.png): https://upload.wikimedia.org/wikipedia/commons/thumb/d/de/Political_map_of_the_World_%28January_2015%29.svg/9444px-Political_map_of_the_World_%28January_2015%29.svg.png
MATLAB commands used:
world=imread('map.png');
imshow(world)
exportgraphics(gcf,'world.pdf','ContentType','vector','Resolution',300)
#Texts in picture is blurry
print -dpdf 'world.pdf'
#Texts in picture is still blurry
exportfig(gcf, 'world.pdf', 'format','pdf','Resolution', 300,'Renderer', 'painters');
#this is a script from the MATLAB file exchange. Texts still blurry
I managed to do it by importing pdfbox (java) and importing the image as a bufferedimage then creating a document with pdmodel.PDDocument then adding a page with a custom size using the bufferedimage.getWidth and same for length then I streamed the bufferedimage to the page and saved the document to a pdf file. The code is on my work PC if anyone is interested I will copy it here.
So I have this png image here
and when I try to read it with tesseract on the command line, I get some random character
❯ tesseract Selection_002.png stdout --psm 7
Warning. Invalid resolution 0 dpi. Using 70 instead.
ale PR Me)
I'm running tesseract version 4.0.0-beta.1-370-g8b64 on ubuntu.
I would have guessed that this image would be easy to read for tesseract?
I've gone through trying to resize the image and "cleaning" it up but there's no much noise to clean on that. What Am I doing wrong?
Please try inverting the image color. (Black text on white).
I tried with your image as well as inverting the color. Both gave successful results.
I'm trying to convert simple image with numbers to text using https://github.com/tesseract-ocr/tesseract. I compiled latest version from github with Leptonica and other libs required for image process.
My image looks like this:
I'm trying to convert it like this: /usr/local/bin/tesseract '/home/var/img2text/phone.png' out but instead of numbers something like 3m mam. what could be the problem?
The image is small and the quality of it is a little low, try the following:
1- Change its DPI to 300
2- Resize the image 2x and apply Resample interpolation.
3- Make sure it is a B/W image.
Here are some useful links:
https://code.google.com/p/tesseract-ocr/wiki/ImproveQuality
image processing to improve tesseract OCR accuracy
I'm trying to convert the image found here pgm image to jpg but I can't. I've tried the answer of the question found here but it didn't work. So, if anyone could please advise.
The problem is in your file-header:
Pf 640 480 9757
According to Wikidepida and this man page your file should use P2 (for the graymap) instead of Pf (which seems to be invalid in all cases):
P2 640 480 9757
With that little change (made in a text editor) your file opens fine.
If you need more faces use the Cambridge's database
And do it like in your link.
$> im = imread( 'file.pgm' );
$> imwrite( im , 'nameForJpg.jpg');
And that's it!
Good Luck!
Live long and prosper!
I am using tesseract open source engine for OCR to read text from image.
But I didn't get 100% result for a single time. Please give your suggestions about quality improvement for OCR using tesseract.
Thanks
here is how to get best result from tesseract
Please make sure that you have done preprocessing on image. OVR will produce best results for the images which have following properties:
fix DPI (if needed) 300 DPI is minimum
fix text size (e.g. 12 pt should be ok)
try to fix text lines (deskew and dewarp text)
try to fix illumination of image (e.g. no dark part of image
binarize and de-noise image
https://groups.google.com/forum/?fromgroups=#!topic/tesseract-ocr/g5aE_OvgyTU