partioning the image
Mostrar comentarios más antiguos
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
Respuestas (1)
Walter Roberson
el 19 de En. de 2012
0 votos
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 comentarios
Pat
el 19 de En. de 2012
Walter Roberson
el 19 de En. de 2012
Please clarify how "frame" relates to your above description. Is a "frame" an individual image?
You did not tell us about zigzag()
It is not clear to me exactly what it is that the centroid is being taken of, but perhaps that would make more sense if I knew about zigzag().
Pat
el 19 de En. de 2012
Walter Roberson
el 19 de En. de 2012
zigzag() is your _implementation_ of an idea; we can see what you are passing in as input, but not what you do with it.
If you are doing CLD then why are you not dividing your image in to 64 blocks (instead of 6), and why are you not applying your algorithm to a color image (your size() call assumes 2D which can only happen with grayscale for .jpg images), and where are the other two DCT matrices and zigzag outputs that would be built for CLD stage 4 and 5? http://en.wikipedia.org/wiki/Color_layout_descriptor
Pat
el 19 de En. de 2012
Walter Roberson
el 19 de En. de 2012
In your Question, above, you wrote, "I want to divide the image into 6 blocks". Did you miss out the "4" of "64" ?
JPEG files can only store grayscale images (2D) or true-color images (3D) and JPEG cannot store indexed images (2D). If you are reading a color image, 3D, then [img_x,img_y]=size(img); is going to get the right number of rows stored in img_x, but the value stored in img_y is going to be the number of columns multiplied by the number of bands (3) . See the last syntax case in the size() documentation.
The DCT stage for CLD produces 3 DCT coefficient matrices; you appear to only be producing one.
Pat
el 22 de En. de 2012
Walter Roberson
el 22 de En. de 2012
Looks to me as if you would have one DCT coefficient matrix per color plane. But first you are going to have to find an image that is simultaneously 3D (truecolor) and not 3D (in order to work with your calls to size())
Pat
el 23 de En. de 2012
Walter Roberson
el 23 de En. de 2012
Can't be. Your line
[img_x,img_y]=size(img);
is only appropriate for 2D images.
Pat
el 24 de En. de 2012
Walter Roberson
el 24 de En. de 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.
Categorías
Más información sobre Simulink en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!