I try to get minimum image size for tesseract, from 300 dpi
to pixel
, in android. I found this answer tell me how to convert dp to pixel, but seems it isn't what I need, as dp = dip = Density-independent pixel
(correct me if I'm wrong). For example, if I have an image with size 1024 x 768 pixels, then how I can get its size base on 300 (dpi) dot per inch?
-
Careful, dp == dip (density independent pixel), but dp != dpi (dots per inch). Exactly what is the conversion you need? – matiash Jun 03 '14 at 03:12
-
I need to convert dpi (dots per inch) to pixels, says I have image with size 1024 x 768 pixels, and I need to get the size 300 dpi – ductran Jun 03 '14 at 03:17
-
1Dots per inch cannot be converted to pixels, they measure different things. It's exactly like trying to convert km/s into meters. – matiash Jun 03 '14 at 03:19
-
ok, so you mean dpi is density of pixels on image, while pixel is a size of image? – ductran Jun 03 '14 at 03:23
-
Yes, of an image or a display (e.g. the nexus 5 has a 450 dpi screen, that is also 1920 pixels tall -- which means that it's 4.2 inches tall). coming back to your original question, I'm not entirely sure what conversion you need :/ – matiash Jun 03 '14 at 03:27
-
Ok, I got it. Thank you. Just because `tesseract` require image has 300 dpi resolution, so i don't know how to do with it. You may want to answer my question then I can accept it. – ductran Jun 03 '14 at 03:40
-
do you want to resize the image – Illegal Argument Jun 03 '14 at 03:57
-
@R4j I tried to expand on it a little bit. Hope it's useful. – matiash Jun 03 '14 at 03:57
1 Answers
A bitmap doesn't have an "inherent" density, only a resolution (i.e. x by y
pixels).
An image file may contain information about DPIs, but that's only for mapping to physical dimensions (i.e. for printing). For example, an 800px * 600px image with a resolution of 96dpi will be printed as 8.33in * 6.25in, while the print area will be smaller for a higher resolution.
Therefore, "pixels to dpi" is not a valid conversion -- it's kind of like converting distance into speed.
I'm not sure about the requirements for tesseract, but if it receives a bitmap as an input then it will be "processing pixels", so I don't think the 300dpi requirement makes sense -- that's probably a rule of thumb to obtain a good result from scanned text of particular (physical) font size.

- 54,791
- 16
- 125
- 154