Compute block-wise standard deviation

2 visualizaciones (últimos 30 días)
sri raj
sri raj el 24 de Abr. de 2016
Respondida: Image Analyst el 24 de Abr. de 2016
i have converted 80*80 image into blocks. next i converted blocks to linear array. now i need to find standard deviation of first 8 arrays. then standard deviation of next 8 arrays and so on. please send code.std2(tv(:,me:nn*nnn), 2). it show error
for i=1:4:nr-3
for j=1:4:nc-3
block=I(i:i+3,j:j+3);
%convert 4X4 into 16X1 column vector
tv(:,col)=reshape(block,16,1);
col=col+1;
count=count+1;
column=column+4;
end
row=row+4;
end
  1 comentario
Jan
Jan el 24 de Abr. de 2016
Please post the code, which produces the error and the complete error message.

Iniciar sesión para comentar.

Respuestas (2)

Matt J
Matt J el 24 de Abr. de 2016
Editada: Matt J el 24 de Abr. de 2016
Not sure I fully understand. You can get the standard deviations of each 4x4 block, all in just 2 lines, by using SEPBLOCKFUN ( Download )
sz=[4,4];
Imeans=sepblockfun(I,sz,@mean);
result=sqrt(sepblockfun(I.^2, sz,@mean ) - Imeans.^2 );
Or, if you set sz=[32,4] this will do the same across blocks of size [32,4] which is what you get if you group consecutive sets of eight 4x4 blocks together.

Image Analyst
Image Analyst el 24 de Abr. de 2016
You can use blockproc:
% Block process the image to replace every pixel in the
% 8 pixel by 8 pixel block by the standard deviation
% of the pixels in the block.
% Image will be smaller since we are not using ones() and so for each block
% there will be just one output pixel, not a block of 8 by 8 output pixels.
blockSize = [8 8];
StDevFilterFunction = @(theBlockStructure) std(double(theBlockStructure.data(:)));
blockyImageSD = blockproc(grayImage, blockSize, StDevFilterFunction);
See attached demos.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by