1

I couldn't find an answer for RGB image.

How can someone get a value of SD,mean and Entropy of RGB image using MATLAB?

From http://airccse.org/journal/ijdms/papers/4612ijdms05.pdf TABLE3, it seems he got one answer so did he get the average of the RGB values?

Really in need of any help.

SeRo
  • 77
  • 4
  • 15
  • How do you _define_ SD, mean etc of a color image? I mean, each pixel has _three_ values – Luis Mendo Jan 30 '15 at 15:36
  • Yeah that is part of the question, if one value to be evaluated from RGB mean, SD and Entropy. Does that mean we have to get the value for each channel and then get their mean ? – SeRo Jan 30 '15 at 15:48
  • How you define the SD, ... depends on what you want to do with it. So why do you need these values? – NoDataDumpNoContribution Feb 18 '15 at 16:03

3 Answers3

5

After reading the paper, because you are dealing with colour images, you have three channels of information to access. This means that you could alter one of the channels for a colour image and it could still affect the information it's trying to portray. The author wasn't very clear on how they were obtaining just a single value to represent the overall mean and standard deviation. Quite frankly, because this paper was published in a no-name journal, I'm not surprised how they managed to get away with it. If this was attempted to be published in more well known journals (IEEE, ACM, etc.), this would probably be rejected outright due to that very ambiguity.

On how I interpret this procedure, averaging all three channels doesn't make sense because you want to capture the differences over all channels. Doing this averaging will smear that information and those differences get lost. Practically speaking, if you averaged all three channels, should one channel change its intensity by 1, and when you averaged the channels together, the reported average would be so small that it probably would not register as a meaningful difference.

In my opinion, what you should perhaps do is treat the entire RGB image as a 1D signal, then perform the mean, standard deviation and entropy of that image. As such, given an RGB image stored in image_rgb, you can unroll the entire image into a 1D array like so:

image_1D = double(image_rgb(:));

The double casting is important because you want to maintain floating point precision when calculating the mean and standard deviation. The images will probably be of an unsigned integer type, and so this casting must be done to maintain floating point precision. If you don't do this, you may have calculations that get saturated or clamped beyond the limits of that data type and you won't get the right answer. As such, you can calculate the mean, standard deviation and entropy like so:

m = mean(image_1D);
s = std(image_1D);
e = entropy(image_1D);

entropy is a function in MATLAB that calculates the entropy of images so you should be fine here. As noted by @CitizenInsane in his answer, entropy unrolls a grayscale image into a 1D vector and applies the Shannon definition of entropy on this 1D vector. In a similar token, you can do the same thing with a RGB image, but we have already unrolled the signal into a 1D vector anyway, and so the input into entropy will certainly be well suited for the unrolled RGB image.

rayryeng
  • 102,964
  • 22
  • 184
  • 193
  • 2
    I would like to thank you for such comprehensive answer. – SeRo Jan 30 '15 at 16:13
  • @LuisMendo - Hehe thanks :) I embellished a little bit. I read the abstract, and skimmed over the introduction and theory. What I focused on was the results section and I read through that. I searched all over to see how they handled the colour image case. They mention they use colour images, but don't talk about how they managed the information on a per channel basis. Given my experience in image processing and what I thought the authors were trying to do, I thus gave my answer. IMO, the paper is rather terrible and if I was a reviewer, I would have rejected it outright. – rayryeng Jan 30 '15 at 16:53
  • @rayryeng I'm not into image processing, but _defining_ the average or std of a multichannel 2D signal is not obvious, and deserves at least some explanation. And if they acually mix all three channels, that sounds a little strange – Luis Mendo Jan 30 '15 at 16:56
  • 1
    @LuisMendo - Definitely! The paper was talking about information hiding and seeing how the image is affected once you place this hidden information in the image. My guess is that they used the average value as a single quantifiable value to see if there were any differences. If the averages are more or less the same, then the information was successful at being hidden... the same goes for `std`. There are comprehensive ways to do that for images, but that is probably due to the author's lack of understanding on how to assess image quality. FWIW, I would have not assessed it this way. – rayryeng Jan 30 '15 at 16:59
2

I have no idea how the author actually did it. But what you could do, is to treat the image as a 1D-array of size WxHx3 and then simply calculate the mean and standard deviation.

Hannes Ovrén
  • 21,229
  • 9
  • 65
  • 75
2

Don't know if table 3 is obtain in the same way but at least looking at entropy routine in image toolbox of matlab, RGB values are vectorized to single vector:

I = imread('rgb'); % Read RGB values
I = I(:); % Vectorization of RGB values

p = imhist(I); % Histogram
p(p == 0) = []; % remove zero entries in p 
p = p ./ numel(I); % normalize p so that sum(p) is one.

E = -sum(p.*log2(p));
CitizenInsane
  • 4,755
  • 1
  • 25
  • 56