필터 지우기
필터 지우기

Compute block-wise standard deviation

조회 수: 1 (최근 30일)
sri raj
sri raj 2016년 4월 24일
답변: Image Analyst 2016년 4월 24일
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
Jan
Jan 2016년 4월 24일
Please post the code, which produces the error and the complete error message.

댓글을 달려면 로그인하십시오.

답변 (2개)

Matt J
Matt J 2016년 4월 24일
편집: Matt J 2016년 4월 24일
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 2016년 4월 24일
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.

Community Treasure Hunt

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

Start Hunting!

Translated by