SOLVED Is image density an actual feature of an image,or merely a means of defining the size of the image in the viewer?
SOLVED Is image density an actual feature of an image,or merely a means of defining the size of the image in the viewer?
Would someone kindly explain to me the purpose of -resample. As I understand the option it is a simultaneous resizing and reset of the density of the image, so that the resampled image will occupy the same physical dimensions when presented in a different viewing device.
Which begs the question, why bother to resize at all, why not keep the original image and simply declare its density to be that desired on the new viewer? Because, by resizing the image by -resample, there is no actual change in the number of pixels (dots) per inch, that is determined only when it is viewed.
Which begs the question, why bother to resize at all, why not keep the original image and simply declare its density to be that desired on the new viewer? Because, by resizing the image by -resample, there is no actual change in the number of pixels (dots) per inch, that is determined only when it is viewed.
Last edited by porphyry5 on 2019-03-26T13:26:09-07:00, edited 1 time in total.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Is image density an actual feature of an image, or merely a means of defining the size of the image in the viewer?
Correct.porphyry5 wrote:Would someone kindly explain to me the purpose of -resample. As I understand the option it is a simultaneous resizing and reset of the density of the image, ...
Yes, provided the display software respects the density setting.porphyry5 wrote:...so that the resampled image will occupy the same physical dimensions when presented in a different viewing device.
However, when displaying an image on the screen, most software will ignore the density setting.
snibgo's IM pages: im.snibgo.com
Re: Is image density an actual feature of an image, or merely a means of defining the size of the image in the viewer?
Thank you for your response, so I take it that -density has no actual meaning beyond being a hint to polite software to display the image at a particular size?snibgo wrote: ↑2019-03-25T17:33:19-07:00Correct.porphyry5 wrote:Would someone kindly explain to me the purpose of -resample. As I understand the option it is a simultaneous resizing and reset of the density of the image, ...Yes, provided the display software respects the density setting.porphyry5 wrote:...so that the resampled image will occupy the same physical dimensions when presented in a different viewing device.
However, when displaying an image on the screen, most software will ignore the density setting.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Is image density an actual feature of an image, or merely a means of defining the size of the image in the viewer?
Yes.
Personally, for my image processing, I usually deal in pixels, not inches or centimetres or whatever. The density and physical dimensions are rarely of any importance.
Personally, for my image processing, I usually deal in pixels, not inches or centimetres or whatever. The density and physical dimensions are rarely of any importance.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Is image density an actual feature of an image, or merely a means of defining the size of the image in the viewer?
Density and physical dimensions are generally only important for printing, but not for display or further processing of the images.
Note that vector files such as SVG, EPS, PDF, PS etc will be rasterized and so will need to have some density set before reading the vector file so that ImageMagick knows how finely to rasterize (convert to pixels) and thus how large the raster image dimension will be.
Note that vector files such as SVG, EPS, PDF, PS etc will be rasterized and so will need to have some density set before reading the vector file so that ImageMagick knows how finely to rasterize (convert to pixels) and thus how large the raster image dimension will be.
Re: Is image density an actual feature of an image, or merely a means of defining the size of the image in the viewer?
Many thanks. I'm sorry if I've been overly persistent on this point, but my end objective is ocr to text with tesseract, which asserts that its ideal density is 300 dpi, but without enlarging on the point. But in practice changing the density made no improvement, and I assumed I was missing some other unstated information. I think it must be important only when starting from a paper document.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Is image density an actual feature of an image, or merely a means of defining the size of the image in the viewer?
As I understand it, the only time you might need a density of 300 dpi is if you started with a vector image. For example if you scanned into a PDF format. Then you would need to specify the density in order to rasterize the PDF file. (Alternately extract any imbedded raster image from within the PDF). See my post above about vector image formats.
For example:
For example:
Code: Select all
convert -density 300 -units pixelsperinch image.pdf image.png
Re: Is image density an actual feature of an image, or merely a means of defining the size of the image in the viewer?
Thank you for your help, all this is to improve my success with tesseract ocr-ing screen-shots of firefox windows to extract their text content. Trial and error has led me to using tiff files exclusively, and as I'm not printing anything, I think now I can safely ignore image density as a factor in that.fmw42 wrote: ↑2019-03-26T12:35:23-07:00 Density and physical dimensions are generally only important for printing, but not for display or further processing of the images.
Note that vector files such as SVG, EPS, PDF, PS etc will be rasterized and so will need to have some density set before reading the vector file so that ImageMagick knows how finely to rasterize (convert to pixels) and thus how large the raster image dimension will be.
As I understand it, the only time you might need a density of 300 dpi is if you started with a vector image. For example if you scanned into a PDF format. Then you would need to specify the density in order to rasterize the PDF file. (Alternately extract any imbedded raster image from within the PDF). See my post above about vector image formats.
For example:
Code: Select all
convert -density 300 -units pixelsperinch image.pdf image.png
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Is image density an actual feature of an image, or merely a means of defining the size of the image in the viewer?
In my limited experience of OCR, the height of capital letters such as HIM should be at least 20 pixels high. Smaller characters give less accuracy. The pixels per inch of the raster image has no importance, as such, but are relevant when typed documents are scanned, eg if a paper document has 8 text lines per inch, the capital height will be about 0.1 inches, so needs scanning at 200 dpi or more to ensure we have 20 pixels per capital.porphyry5 wrote:... my end objective is ocr to text with tesseract, which asserts that its ideal density is 300 dpi, but without enlarging on the point.
As Fred says, when reading a vector format, the density setting before rasterizing the input file is important, but can be changed in the resulting raster image.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: SOLVED Is image density an actual feature of an image,or merely a means of defining the size of the image in the vie
snibgo is correct. I forgot about the density needed when scanning a document into raster format. So if you were told to scan at 300 dpi, then go ahead and do that. As snibgo said, the larger the text, the better the OCR. Of course you need to balance that against file size if you are going to save the scanned documents.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: SOLVED Is image density an actual feature of an image,or merely a means of defining the size of the image in the vie
Image Density or Resolution
http://www.imagemagick.org/Usage/basics/#density
http://www.imagemagick.org/Usage/resize/#resample
Pointsize, Density and the Actual Font Size (or images)
http://www.imagemagick.org/Usage/text/#pointsize
Aside: I have updated the 'basic' description which seems to have a lot of duplication of description to make it work better. This will appear in couple of hours or so.
http://www.imagemagick.org/Usage/basics/#density
Resample - Changing an image's resolutionThe density of an image is completely irrelevant to the actual images pixel size. It is just a set of numbers stored with the image to tell output devices such as printers and displays how many dots (or pixels) per inch the image should be displayed at, OR for vector formats like postscript, PDF, MWF, and SVG the pixel scale to draw using any real world coordinates that may be used within the image.
For more information on Resolution and Density of images see the notes on the Resample Resize Operator. For information of Resolution and Density for Text and Fonts see Pointsize and Actual Font Size.
http://www.imagemagick.org/Usage/resize/#resample
Pointsize, Density and the Actual Font Size (or images)
http://www.imagemagick.org/Usage/text/#pointsize
Aside: I have updated the 'basic' description which seems to have a lot of duplication of description to make it work better. This will appear in couple of hours or so.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/