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?

up vote 5 down vote accepted

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?

  • 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. – dgatwood Aug 22 '17 at 22:47
  • 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! – Sinus Mackowaty Aug 30 '17 at 7:44

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.

  • 1
    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. – Sinus Mackowaty Aug 22 '17 at 1:33
  • 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. – StephenG Aug 22 '17 at 4:22
  • I'm generally aware of how gradient detection algorithms work, and I'm probably able to write a simple analysis function if I need to. I thought I'd ask first, though, before I set about reinventing the wheel. :) – Sinus Mackowaty Aug 22 '17 at 17:53
  • 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. – Sinus Mackowaty Aug 22 '17 at 18:01
  • The papers I'm suggesting you'll find are not gradient detection algorithms. From a practical point of view in scanning that many images I'd not worry about the scan quality so much as automating the mechanics of the process itself. There are many DIY projects on the web about DIY slide digitizing like this one on Hack-a-day. – StephenG Aug 22 '17 at 18:38

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.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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