0

I am completely confused by

Relationship between dpi and figure size

Why does a higher DPI give you coarser features? Shouldn't it give you finer features? Can someone please explain?

adam.hendry
  • 4,458
  • 5
  • 24
  • 51
  • It depends on what you understand by "coarser": assuming we have a two figures 3x3 inches with a line thas is 0.1 inch thick. One fig is 100 dpi and the other 10 dpi. With 100 dpi this line is 10 pixels thick and with 10 dpi it's 1 pixel thick. If you print out both figures (yielding the same size on paper) there's no difference if we have exactly horizontal or vertical lines. But if we have e.g. a circle than the 10 dpi circle will appear more ragged (at least if you switch of antialiasing). So it is coarser in this sense, although the line width on paper will be the same. – Stef Jul 23 '20 at 10:50
  • As for the [linked answer](https://stackoverflow.com/a/47639545/3944322) you may be mislead by the fact that the same 2x2 fig (left column) is shown the bigger on the screen the higher the dpi value, but if you pint in on paper all 2x2 figures will be 2x2 inches. – Stef Jul 23 '20 at 10:53
  • @Stef Yes, thank you for your answer. It does confuse me that the left column figures get bigger with higher dpi. For digital image processing, if I load an image scanned at 300 dpi and one at 600 dpi, am I unable to differentiate because matplotlib always uses 72 dpi by default? – adam.hendry Jul 23 '20 at 14:15
  • The 72 mentioned in the linked answer is not dpi but ppi (points per inch, i.e. how big one point - not one pixel - is). As far as I know this can't be changed. The default dpi is 100 dpi. As to your actual question I _think_ (not verified) that even if your png files contain dpi headers and you show the images with `imshow` you'll get equal sized firgures as matplotlib just shows the given number of pixels in the chosen figure size (not sure if I understood your question correctly though). – Stef Jul 23 '20 at 14:27
  • @Stef Oh I see, thank you. Proper usage of the terms ppi vs dpi is always a source of confusion. Thank you for your clarification. I think I see now. Image resolution is set at the time of scanning. I'll see a crisper image scanned at 300 dpi vs, say, 200 dpi. However, on screen, both images would be the same size and have the same number of pixels. The increased "resolution" I would perceive would most likely be from the difference in halftone representation at each pixel. Do you agree with this? – adam.hendry Jul 23 '20 at 14:48
  • @Stef [Continuation...] Changing the dpi in matplotlib after the fact affects how the image is printed out on paper, but since ppi is fixed for the computer monitor, increasing the dpi has the effect of making it appear "bigger". – adam.hendry Jul 23 '20 at 14:51
  • I agree with the first comment. As for the second, point in ppi is meant to be a [typographic point](https://en.wikipedia.org/wiki/Point_(typography)), it has nothing to do with the computer monitor. The monitor displays the given number of pixels and if you have more pixels then you get a bigger image (on the same monitor). – Stef Jul 23 '20 at 15:16
  • @Stef Oh okay. I just meant that since Matplotlib uses 72 points per inch (ppi) by default, if you print to monitor at 72 dots per inch (dpi), it will appear 1:1, but at 144 dpi, it will appear 2:1 because of the fixed ppi. When printing to paper, the extra pixels get utilized by the printer halftoning/dithering algorithm and the physical size of the image remains the same. Is this explanation right? – adam.hendry Jul 23 '20 at 15:42
  • Yes, I thinks so. – Stef Jul 23 '20 at 15:45

0 Answers0