How to write own standard deviation function.
Mostrar comentarios más antiguos
I have read the color image. Then separated RGB values into three different arrays. After that I have written my own function to calculate standard deviation function for each color component. But when I execute my own written function and in built function I got different values? What is wrong int it?
without inbuilt function
im = imread('D:\im112.jpg');
R=im(:,:,1)
[r,c]=size(R);
totmean=sum(R(:))/(r*c);
totdiff=(R-totmean).^2;
totsum=sum(totdiff(:));
nele=(r*c)-1;
totvar=totsum/nele;
totstd=sqrt(totvar);
display(totstd);
Using inbuilt functio
stdr=std(double(R(:)))
1 comentario
Respuesta aceptada
Más respuestas (2)
Andrei Bobrov
el 20 de Jul. de 2016
n = numel(R);
yourstd = sqrt(sum((R(:) - sum(R(:))/n).^2)/(n - 1));
Image Analyst
el 20 de Jul. de 2016
Why not simply use std2() - the built in function meant for this????
img = imread('moon.tif');
s = std2(img) % No casting to double needed.
Categorías
Más información sobre Image Processing Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!