Getting Standard Deviation for Image based on normalized color band
이전 댓글 표시
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?
채택된 답변
추가 답변 (2개)
Walter Roberson
2015년 8월 1일
0 개 추천
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
Chitrarth Lav
2015년 8월 1일
Walter Roberson
2015년 8월 1일
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
2015년 8월 2일
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);
카테고리
도움말 센터 및 File Exchange에서 Blue에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

