Getting Standard Deviation for Image based on normalized color band
Afficher commentaires plus anciens
I need to evaluate the SD for an imported image (PNG). The thing is the image actually represents a color band from 0 - 1 (blue - red) and the SD is calculated for the about the mean i.e SD of (conc - 0.5). How do I implement this in MATLAB? I tried using mat2gray to normalize the matrix and used std2 but the result doesn't quite match. It seems I need to normalize on the band -0.5 to 0.5 but not really sure. Suggestions?
Réponse acceptée
Plus de réponses (2)
Walter Roberson
le 1 Août 2015
0 votes
std() always subtracts the mean so you do not need to shift the mean before you do std().
However, std() is sensitive to the range of values: multiplying the range by a factor of alpha multiplies the standard deviation by alpha.
2 commentaires
Chitrarth Lav
le 1 Août 2015
Walter Roberson
le 1 Août 2015
PNG files cannot store floating point, so you will find that the data read in is in the range 0 to 255 (or less.) im2double() will convert that to the 0 to 1 range.
Image Analyst
le 2 Août 2015
Are you saying that you have a PNG image that goes from blue to red, so that the green channel is always 0. And if the color is pure blue (red component = 0) then this represents a "0" and if the color is pure red (with a blue component = 0) then this represents a 1? So that the blue plus red components added together always give 255? If so, you can convert this image into a 0 to 1 image this way
rgbImage = imread(filename);
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Create an image where blue goes to 0, red goes to 1
% and it's linearly scaled in between based on how much blue and red there is.
outputImage = double(redChannel) / 255;
% Now get the standard deviation
stDev = std(outputImage);
Catégories
En savoir plus sur Blue dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

