partioning the image

1 次查看(过去 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