partioning the image

1 Ansicht (letzte 30 Tage)
Pat
Pat am 19 Jan. 2012
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

Antworten (1)

Walter Roberson
Walter Roberson am 19 Jan. 2012
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 Kommentare
Pat
Pat am 24 Jan. 2012
walter when i give
A=size(img),the output is 256x256x3
[img_x,img_y]=size(img);
i get 256x1450
Walter Roberson
Walter Roberson am 24 Jan. 2012
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Simulink finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by