1
$\begingroup$

I have an algorithm that outputs gray scale images (not normalized). These images often contain a lot of random noise and sometimes also contain spatial structures.

I would like to have some kind of measurement to compute how random an image is. Random images should have a low score whereas images with structures should score higher. Ideally the score should be in an range so that I can compare images with each other. Something like:

  • 0 = image consists purely of random noise
  • 1 = image contains clear and sharp structures (whatever that would mean)

The first thing that came into my mind was computing the Shannon entropy of each image but I ended up with a lot of questions:

  • What is the correct way to normalize the images or more specifically, how many gray levels should the image have? 8 or 256 or something else?

  • Which base of the logarithm should I use? Common is 2 but also $e$ and 10.

  • Do I compute the entropy for the whole image or do I compute the entropy of patches of size $m \times m$ around a pixel $(i,j)$ and sum up the entropy afterwards?

  • Does Shannon's entropy really take spatial structures into account? It seems to me, that the definition only looks locally at a single pixel. Is that right?

In some articles about Shannon's entropy the co-occurrence matrix was mentioned which can measure the texture of the image.

  • Is that a better way to go for my problem? How can I use this for my purpose?

  • I read that this method provides some statistics I have problems to understand. Articles about co-occurrence matrices mentioned Contrast, Correlation, Energy and Homogeneity as a tool to analyze an image. Which one should I consider for a distinction between images that with a lot of random noise and images with sharp structures?

$\endgroup$
2
  • $\begingroup$ Have you examined this answer yet? It seems to address most of your issues quite well with respect to binary 2D datasets/images. The essential idea is to examine local entropy at a series of different scales. It might help to edit to re-focus your question on the additional issues introduced by having other than binary data. $\endgroup$
    – EdM
    Commented Jul 24, 2018 at 15:36
  • $\begingroup$ See also this answer, I think it should answer to your question: stackoverflow.com/a/42059758/2627237 $\endgroup$
    – reima
    Commented Jul 26, 2018 at 12:44

2 Answers 2

1
$\begingroup$

There are the NIST SP 800-90 series of test for randomness (with source), specifically:

Discrete Fourier Transform (Spectral) Test

Description: The focus of this test is the peak heights in the discrete Fast Fourier Transform. The purpose of this test is to detect periodic features (i.e., repetitive patterns that are near each other) in the tested sequence that would indicate a deviation from the assumption of randomness.

2nd Question:

Is that a better way to go for my problem? How can I use this for my purpose?

There's a StackOverflow Q&A on feature detection/extraction: Difference between Feature Detection and Descriptor Extraction and DSP.SE's Purpose of image feature detection and matching, while not calculating randomness (as the prior example does) it can classify the features in case there's something you want to exclude.

There's the power of Cloud Computing, for example: Google's Cloud Vision API, again this won't say if "it is random" but if it isn't random it will tell you what is in the photo. It's quick and using very few of your CPU cycles to obtain the answer.

Once you know 'what and where' you can subtract it from the image and test for randomness on the remainder.

$\endgroup$
0
$\begingroup$

You are likely going to be best off with some kind of compression based approach - in particular, since you don't have a clear idea of the scale at which to measure things.

Let $C(\cdot)$ be a compression function. Generate a purely random image (i.e., pure noise), $N$. Then, one can use the ratio $\frac{C(A)}{C(N)}$. to capture how much randomness is in $A$ relative to the pure noise.

$\endgroup$
2
  • $\begingroup$ Can you please be more specific about the compression function? What would an approach in python for such a function? $\endgroup$
    – Gilfoyle
    Commented Jul 26, 2018 at 11:06
  • $\begingroup$ You should likely be looking at a wavelet based approach which can capture information at different scales - e.g. see pdfs.semanticscholar.org/10bc/… $\endgroup$
    – MotiNK
    Commented Jul 26, 2018 at 11:55

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.