How to find Summary Statistics of Image in Matlab

15 Ansichten (letzte 30 Tage)
Muhammad Usman Saleem am 18 Dez. 2021
Kommentiert: Image Analyst am 31 Dez. 2021
I've MODIS satellite raster (tiff image) and this raster is of evapotrainspiration (ET) dataset collected by this satellite. I want to find mean ET over my study area, however, this mean value of the raster is different from the mean value of the ET calculated in ESRI software e.g., ArcGIS. I am using this simple code
imm=im*0.1 %multipling scale factor according to MODIS documentation
imm(imm == 65535) = nan; %datavalues outside the study area as nan
nemean=mean2(imm)
The mean value comes:
nemean =
4.9621
But the actual mean value of ET is
337.422222
i'm sharing ET image with this question. Why mean value of raster comes different in matlab? I think, I'm doing some mistake please correct?
0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst am 19 Dez. 2021
Perhaps you have the wrong image. The images has values only up to a gray level of 71, if you don't count all those values that are saturated at 65535. And the mean is 20.621096. How are you defining your "Study area"? There are no values around 337 or 10 times that in the image.
% imm=originalImage*0.1 %multipling scale factor according to MODIS documentation
subplot(2, 2, 1);
imshow(originalImage, [])
title('Original 16 bit image');
subplot(2, 2, 2);
[counts, edges] = histcounts(originalImage, 65536);
% Suppress huge spikes at 0 and 65535
counts(1) = 0;
counts(end) = 0;
% Find last non-zero bin
lastBin = find(counts > 0, 1, 'last')
bar(edges(1:lastBin), counts(1:lastBin))
grid on;
title('Histogram')
% Change 65535 to 0.
subplot(2, 2, 3);
caption = sprintf('Mean = %f', meanGrayLevel)
title(caption);
7 Kommentare5 ältere Kommentare anzeigen5 ältere Kommentare ausblenden
Muhammad Usman Saleem am 31 Dez. 2021
One more task I needed, I want to skip pixel values ranging 32761 to 32767 and 65536 while calculating mean of pixel values falling within my shapefile domain. Will you please edit your kind answer so that I skip pixel values ranging from 32761 to 32767 ( by MODIS documentation this range contains buildup landcover) and 65536 (Background), I not need these pixel values in my Mean value. Please modify your kind code.
Image Analyst am 31 Dez. 2021
clc; % Clear the command window.
fprintf('Beginning to run %s.m ...\n', mfilename);
close all; % Close all figures (except those of imtool.)
clearvars;
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 18;
% imm=originalImage*0.1 %multipling scale factor according to MODIS documentation
subplot(2, 3, 1);
imshow(originalImage, [])
impixelinfo;
title('Original 16 bit image');
subplot(2, 3, 2:3);
[counts, edges] = histcounts(originalImage, 65536);
% Suppress huge spikes at 0 and 65535
counts(1) = 0;
counts(end) = 0;
% Find last non-zero bin
lastBin = find(counts > 0, 1, 'last')
bar(edges(1:lastBin), counts(1:lastBin))
grid on;
title('Histogram')
% "I want to skip pixel values ranging 32761 to 32767 and 65536"
% There is no 65536 so I'll assume you mean 65535.
pixelsToExclude = (originalImage >= 32761 & originalImage <= 32767) | (originalImage >= 65535);
subplot(2, 3, 4);
imshow(pixelsToExclude, [])
title('Pixels to Exclude');
% The pixels to consider is just the inverse of the pixels we want to exclude.
subplot(2, 3, 5);
title('Pixels to Include');
subplot(2, 3, 6);
caption = sprintf('Mean = %f', meanGrayLevel)
title(caption);

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Image Arithmetic finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by