3

I have encountered a, to me, strange behaviour in the histogram function of QGIS (2.2.0 Valmiera on Windows 7). Basically the same image produces totally different histograms.

I might have missed something fairly obvious, but I'm not able to find out what, and I have not been able to find any previous questions on the matter.

Background
I aim to do a "Black object subtraction" in order to correct for atmospheric noise in satellite images. Without getting too technical about that, I'm looking for the lowest pixel values with a frequency of at least 1000 pixels (a suggested method according to the literature).

Problem
When I calculate a histogram for my SPOT5 image, the maximum frequency of any pixel value is below 1000 (accept for 0, that indicates no data). I find that suspiciously low, as the image is 7900*7900 pixels.

Comparison of histograms
enter image description here

However, if I save the picture to with QGIS, just as it is, without any modification (see attached screen dump of save dialogue), I get a totally different histogram, that looks way more plausible to me (see image above).

Save dialogue
enter image description here

Question
How come that the basically the same raster produce totally different histograms? Is this a bug in QGIS? Faulty handling of images by me? Two different ways of rendering histograms?

  • Just a hunch: Is the original file a GeoTiff where the statistics have not yet been computed? You could check that under Properties -> Metadata – Kersten Oct 28 '15 at 16:17
  • @Kersten Thank you for the suggestion. When I check the metadata there is a lot of numerical information about each band, so I guess that's not the case. It looks like this: Band Band 2 Band No 2 Min Val 0.0000000000 Max Val 255.0000000000 Range 255.0000000000 Mean 35.3649441154 Sum of squares 68164335738.9491653442 Standard Deviation 32.9859098406 Sum of all cells 2215507654.0000000000 Cell Count 62647000 – Smerla Oct 28 '15 at 16:29
  • 1
    the histograms look identical, except the frequencies on the right are about 16x higher - perhaps qgis is using a 1/4 resolution pyramid to compute the frequencies of the one on the left? – Steven Kay Oct 28 '15 at 17:17
  • @StevenKay. Although I'm not sure if I agree that they look exactly identical, I guess you might be right. Seems like a plausible explanation.Thank you! – Smerla Oct 29 '15 at 17:00
2

I am not answering directly the QGIS issue about histogram, but rather questioning the method you used to select the dark pixel in the DOS method.

An absolute threshold based on the frequency of a value in the histogram will provide different results depending on the resolution, on the the number of pixels of the image, or on the number of bits used to code it. I would rather recommend a relative threshold based on the cumulative histogram : for instance 0.1% of the pixels (this value is just a guess, you might need to tune the threshold a little bit).

  • Thank you for the input @O-Hagolle. I think you have a good point and will do as you suggested! Unfortunately, I do not have enough reputation to vote up your answer. And as it is not an answer to the specifik question it unappropriate to flag it as the "correct" answer. – Smerla Dec 13 '15 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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