1. I have images that I want to feed to an OCR engine. The OCR states that the optimal recognition happens when the given image is at 300dpi. How can I convert any image to 300dpi? How can I calculate how much scaling it needs in order to be at 300dpi?
2. Second related question: How can I calculate how many dpi is my screen?
Convert to 300dpi
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Convert to 300dpi
-resample 300
See IM examples, resize, resample
http://www.imagemagick.org/Usage/resize/#resample
As for your screen -- measure it! it is typically (these days) 90 to 120 dpi. Remember dpi = Dots per inch! Yes it is a little archaic.
See IM examples, resize, resample
http://www.imagemagick.org/Usage/resize/#resample
As for your screen -- measure it! it is typically (these days) 90 to 120 dpi. Remember dpi = Dots per inch! Yes it is a little archaic.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Convert to 300dpi
Thanks once again anthony!
1. I used -resample 300 (end image is about 700% bigger) and the OCR result is actually 1 error more than the -scale 400% method (end image is 400% bigger).
Does -resample use a different algorithm for scaling from -scale?
2. How can I measure my screen? I don't understand.
1. I used -resample 300 (end image is about 700% bigger) and the OCR result is actually 1 error more than the -scale 400% method (end image is 400% bigger).
Does -resample use a different algorithm for scaling from -scale?
2. How can I measure my screen? I don't understand.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert to 300dpi
Get the resolution from the display such as 1024x920 pixels.2. How can I measure my screen? I don't understand.
Get the physical dimension of width and length in inches using a ruler.
Divide the width in pixels by the width in inches (or the height in pixels by height in inches).
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Convert to 300dpi
-resample uses a -resize, with the new size calculated using the resoultion.galv wrote: I used -resample 300 (end image is about 700% bigger) and the OCR result is actually 1 error more than the -scale 400% method (end image is 400% bigger).
Does -resample use a different algorithm for scaling from -scale?
If the input image has no resolution set it has a default resolution of 72 dpi which is probably wrong!!!!
To give the the input image a initial resolution, use...
Code: Select all
convert -density ??? {image}
-scale (or even -sample for enlargement) only doubles up pixel rows and columns so if the input was a bitmap, output is a bitmap.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Convert to 300dpi
Is there a way to make -resample use a -scale instead of a -resize?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert to 300dpi
just use -scale and -density to get the pixel resolution and density you want.
Re: Convert to 300dpi
I suspect the OCR code means by "optimal" that it runs the fastest assuming a reasonably-sized font, not necessarily the most reliably. Try to avoid resampling unless you are hurting for speed. I'd be VERY surprised if the OCR code actually got more reliable after you downsampled! Secondly, DPI should not be confused with resolution. Some file formats include a DPI value and others do not. The DPI is strictly for indicating print and display sizing. For file types that do not include that (and for some print drivers and display apps that ignore the DPI in a file, if its there) the image will be displayed (printed) one-to-one pixels by default. If you're concerned about both reliability and speed, then I recommend ignoring that statement about DPI and just experimenting.