partioning the image

조회 수: 14 (최근 30일)
Pat
Pat 2012년 1월 19일
I want to divide the image into 6 blocks ,i used the code below,now i want to display those divided blocks,can tell how to display it please,I am performing CLD,PLEASE tell hoe to calculate the centroid from "out"
img=imread('dock.jpg')
[img_x,img_y]=size(img);
block_size=8;
slide_len=1;
for ix=block_size/2:slide_len:img_x-block_size/2
for jy=block_size/2:slide_len:img_y-block_size/2
current_block=img((ix-block_size/2+1):(ix+block_size/2),(jy-block_size/2+1):(jy+block_size/2));
dct_coeff=reshape(dct2(current_block),1,block_size^2);
out=zigzag(dct_coeff)
end
end

답변 (1개)

Walter Roberson
Walter Roberson 2012년 1월 19일
Your code is overwriting your "out" matrix in each iteration, so at the end of the loop it does not have the necessary information to display all of the blocks.
You have not told us enough about zigzag() for us to predict what operations could be performed on "out".
  댓글 수: 12
Pat
Pat 2012년 1월 24일
walter when i give
A=size(img),the output is 256x256x3
[img_x,img_y]=size(img);
i get 256x1450
Walter Roberson
Walter Roberson 2012년 1월 24일
And if it is not appropriate for your code to think that img_y is 1450 (or, more likely, 768) then you will need to change that line of code.

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

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by