9
\$\begingroup\$

Let's take image A: 2560*1920 pixel image in perfect focus. Sharp as a razor. That's 5 Mpix.

Let's take image B: image A resized to 5120*3840. It's now a 20 Mpix file, but there's no new data in the image, so - using common sense - it's still just a 5 Mpix file, just "bloated".

Theoretically, one should be able gradually to reduce image B's dimensions until reasonable sharpness is detected (bringing it as close to image A as possible, although without actually comparing them at this point), and thus derive the image's "true" megapixel count: the size below which imagery is starting to lose its details.

This value could easily be used to determine the usefulness of a photo - if I shoot it slightly out of focus, I can still print it in a smaller size, and no-one will notice. Or, it could help with assessing lens or sensor quality - if a 24 Mpix camera is unable to capture an image with more than "true" 8 Mpix, then something isn't right.

So, cutting to the chase: is there a software program that does just that? Or am I doomed to writing my own?


From a comment by the OP to one of the answers:

I need to measure how much detail is my positive transparency scanner really getting, before I scan a collection of about 2000 old slides and consider it digitized. If I set it to optical 19200 dpi or something, and it keeps producing images with detail lost, equal to, say, a 5 Mpix camera, then I'll know it's bad.

This is the actual problem the question wants to solve. Everything above is about one perceived solution to that root problem.

\$\endgroup\$
3
  • \$\begingroup\$ I like the question. From a photographers perspective I agree with StephenG's answer, but from an IT Engineer's perspective I disagree. But then the question might be better placed at DSP SE: dsp.stackexchange.com \$\endgroup\$
    – pLumo
    Commented Aug 22, 2017 at 11:16
  • \$\begingroup\$ Related: dsp.stackexchange.com/questions/35490/… \$\endgroup\$
    – pLumo
    Commented Aug 22, 2017 at 11:17
  • \$\begingroup\$ From a comment by the OP to one of the answers: "I need to measure how much detail is my positive transparency scanner really getting, before I scan a collection of about 2000 old slides and consider it digitized. If I set it to optical 19200 dpi or something, and it keeps producing images with detail lost, equal to, say, a 5 Mpix camera, then I'll know it's bad." This is the true problem needing to be solved here. The way this question is asked is an X→Y problem. That is, the OP is asking how to accomplish a perceived solution, rather than asking how to solve the root problem. \$\endgroup\$
    – Michael C
    Commented Apr 29, 2019 at 8:46

3 Answers 3

4
\$\begingroup\$

One approach might be to compute the two-dimensional Fourier transform of the image and try to decide the spatial frequency above which the transform (or, say, it's power) becomes noise, that is, uncorrelated and small. Never tried anything like this, but it must be connected in some way with a rigorous definition of resolution?

\$\endgroup\$
2
  • \$\begingroup\$ Agreed; either a 2D FFT or a 2D discrete cosine transform (DCT) would be the most straightforward approach for computing the effective resolution of an image. With that, you could recognize when the resolution became limited regardless of whether it was caused by the quality of the glass, incorrect focusing, diffraction limiting, heavy image compression, etc. \$\endgroup\$
    – dgatwood
    Commented Aug 22, 2017 at 22:47
  • \$\begingroup\$ That's what I was thinking, too, I just thought someone might have built a tool like that already. This should effectively answer the question "does this image make full use of its resolution", and after some calibration should make it comparable to other sizes. I'll go with this one. Thanks! \$\endgroup\$ Commented Aug 30, 2017 at 7:44
5
\$\begingroup\$

Theoretically, one should be able gradually to reduce image B's dimensions until reasonable sharpness is detected (bringing it as close to image A as possible, although without actually comparing them at this point), and thus derive the image's "true" megapixel count: the size below which imagery is starting to lose its details.

You're starting out assuming that image B has no more detail. But even a completely flat region has detail - it's just that it's flat.

A lack of detail or change does not denote a lack of valid image data or resolution.

This value could easily be used to determine the usefulness of a photo - if I shoot it slightly out of focus, I can still print it in a smaller size, and no-one will notice.

This won't work as you think.

People, in my experience, don't care about detail in an image as much as they acre about emotional and/or informational content. What the image makes them feel or what the image tells them or both.

Unless an image is in exceptionally poor focus it's generally OK for some purpose. The only people, in my experience, who care about perfect focus are photographers and media editors (and the editors are getting less fussy these days).

I had a (technically) bad photo of a relative's daughter one time which had motion blur, camera shake, poor focus and lousy lighting.

It's been pinned to their photo wall for over a decade. No protest by me or offer to shoot it again has ever worked, BTW. They like that photo.

The value of an image is not defined by it's sharpness or resolved detail except in very particular commercial settings and even there it's not main the priority. No news editor will care how little detail there really is in e.g. that "exclusive" shot of some celebrity on holiday or, indeed, some victim of the latest outrage.

Or, it could help with assessing lens or sensor quality -

They have resolution charts for that. Those are well defined fixed patterns and suited to computer analysis. Have a look at DxOMark's website sometime.

Testing resolution against anything but a well defined and precisely known target is pointless.

if a 24 Mpix camera is unable to capture an image with more than "true" 8 Mpix, then something isn't right.

Just because a sensor doesn't capture more detail doesn't mean there is anything wrong apart from your expectations.

Detail captured depends on many factors. First the existence of detail. Then the shooting conditions, the aperture and optical characteristics of the lens. The lighting, the shutter speed, ISO and noise characteristics. Diffraction limitations.

The reality is that pixel counts have very less in practice to do with how much detail you really get when shooting that many other factors which limit what is possible or practical.

\$\endgroup\$
7
  • 3
    \$\begingroup\$ Although many of your points are valid, they only respond to specific cases of the possible uses I mentioned. Plain, featureless gradients are obviously unmeasurable using the methods I'm imagining, but they're a fringe case. Resolution charts won't help with damaged or miscalibrated lenses. DxOMark's "perceptual megapixel" has been widely disputed. Sure, slightly out-of-focus images are sometimes just as useful, but what about REALLY blurry ones? They can be turned into thumbnails or other miniatures, but that is usually determined "by eye", while it could be calculated to some degree. \$\endgroup\$ Commented Aug 22, 2017 at 1:33
  • \$\begingroup\$ If you particularly want to do this do a web-search for "measure for image sharpness" which will give you some links to research papers on this subject. If you're not mathematically inclined then I'd suggest skipping this. You may track down some open source code for this but I'm not aware of any myself. \$\endgroup\$ Commented Aug 22, 2017 at 4:22
  • 2
    \$\begingroup\$ And, to add another point to the "flat surfaces" argument: this is exactly what I mean, as one of examples. A photo of a flat surface without a lot of edges and detail could, technically, be taken with a way poorer camera, with no quality lost at all. In a specific practical case, I need to measure how much detail is my positive transparency scanner really getting, before I scan a collection of about 2000 old slides and consider it digitized. If I set it to optical 19200 dpi or something, and it keeps producing images with detail lost, equal to, say, a 5 Mpix camera, then I'll know it's bad. \$\endgroup\$ Commented Aug 22, 2017 at 18:01
  • 1
    \$\begingroup\$ If I find out that the scanner I have is crap and I could do way better by buying a different one, I'll waste quite a lot of time building the automation mechanics, whatever they are. I'd rather not curse myself forever for screwing up the only time I'll get around to going through with it :) \$\endgroup\$ Commented Aug 31, 2017 at 0:16
  • 1
    \$\begingroup\$ "(and the editors are getting less fussy these days)." Only when they're not paying for the image. \$\endgroup\$
    – Michael C
    Commented Apr 29, 2019 at 8:42
2
\$\begingroup\$

After some experimenting I ended up making a series of downscaled images, upscaled back and compared to the original. If there was a significant maximum difference in pixel values, quality is deemed lost. If there is little loss, it means the original photo was not great to begin with. I'll post a PHP snippet later.

Sadly, images that are directionally blurred, or are blurred but have some sharp artifacts from processing, end up judged as sharp - and I don't think there's a way around this.

\$\endgroup\$
2
  • \$\begingroup\$ What type of resampling did you do when upscaling? Nearest neighbor, linear interpolation, quadratic interpolation, Gaussian, Dodgson, or something else? \$\endgroup\$
    – Michael
    Commented May 15, 2019 at 20:17
  • \$\begingroup\$ @Michael: IIRC, I used linear for simplicity's sake. \$\endgroup\$ Commented May 16, 2019 at 21:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.