Reputation: 1
I want to partition a PGM image into overlapping blocks and do a DCT transformation to every block. Then I want to take the first column of each DCT matrix and put them all to a new matrix.
I have read the answer to the post: How to partition an image to 64 block in matlab, but I am not sure it's working properly. Can I use blockproc
function to make overlapping block and if I can how am I supposed to use it?
I would prefer an answer with for loops.
Upvotes: 0
Views: 2669
Reputation: 21
I=im2double(rgb2gray(imread('yourimage.png'))); %select channels separation
%%%for non-overlapping blocks
fun = @(block_struct) dct2(block_struct.data);
imageY =(blockproc(I,[8 8],fun));
BY=im2col(imageY,[8 8],'distinct');
FinalOP=BY(1:8,:);
%dct-8x8 ,if you want u can choose [64 64].
%you need the first column of dct?.so ,i.e 8 values of dct in this case.
for overlapping blocks: use 'sliding'
but you get memory problem.
then you have to use your own for loop.
Upvotes: 2