Prev: neural network
Next: Identify colors in an RGB image
From: yigit ozsahin on 4 Jun 2010 06:36 Hi everyone I would like to write an algorithm for solving this question. Could you help me with writing a script. 1)I want to sub-block a 512x512 image to 8x8 sub-blocks 2)Transform each block using 2-D DCT( with dct2 command) 3)For each sub-block I want to keep only a fixed set of 10 coefficients and set others to zero.(Same set of coefficients should be kept for all sub-blocks) 4)Reconstruct the image by using (idct2 command) 5)Computing the PSNR between reconstructed and the original images. I used blkproc but I don't know how to keep only 10 coefficients and set others to 0 because the command does not provide 64x64 block set could you help me with solving this problem.
From: yigit ozsahin on 4 Jun 2010 09:13 can anyone know a solution about this ?
From: Steven Lord on 4 Jun 2010 09:21 "yigit ozsahin" <yigitozsahin(a)gmail.com> wrote in message news:huakuk$7lh$1(a)fred.mathworks.com... > Hi everyone I would like to write an algorithm for solving this question. > Could you help me with writing a script. > 1)I want to sub-block a 512x512 image to 8x8 sub-blocks > 2)Transform each block using 2-D DCT( with dct2 command) > 3)For each sub-block I want to keep only a fixed set of 10 coefficients > and set others to zero.(Same set of coefficients should be kept for all > sub-blocks) > 4)Reconstruct the image by using (idct2 command) > 5)Computing the PSNR between reconstructed and the original images. > > I used blkproc but I don't know how to keep only 10 coefficients and set > others to 0 because the command does not provide 64x64 block set could you > help me with solving this problem. Post the code that you've written and indicate where you're stuck and to which step of your procedure above that corresponds. If you do that, then as people get to the office and have their morning coffee, they can read what you've tried and possibly offer suggestions. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
From: yigit ozsahin on 4 Jun 2010 15:59 I wrote this code -------------------------------------------------------------------------------------------------- load lena512.mat %loads lena 512 to workspace I=lena512; % I become lena512 fun = @dct2; %dct2 is assigned as function J = blkproc(I,[8 8],fun); % blkproc function subblocks the image by 8-8 and usign dct2 function figure imshow(uint8(J)) % plot the subblocked image title('lena512 subblocked to 8x8 using dct2 function') %title of the code ------------------------------------------------------------------------------------------------ but i dont know how to do step 3. For each subblock, keep only a fixed set of 10 coefficients and set others to zero (Same set of coefficients should be kept for all subblocks). I also check up for this code for my solution but did not figure out how to do step 3 load lena512.mat; M = lena512; bs = [8 8] % size of the block % % step 1 divide into blocks szM = size(I1) nb = ceil(szM ./ bs) % number of blocks in each dimension C = mat2cell(M,repmat(bs(1),1,nb(1)), repmat(bs(2),1,nb(2))); I do not want to be rude. Saw lots of people read this thread and could not gave an answer and I update the thread. Also lots of people asking from different countries we don't have the same time zone.
From: Leena Silvoster on 5 Jun 2010 01:10
On Jun 5, 12:59 am, "yigit ozsahin" <yigitozsa...(a)gmail.com> wrote: > I wrote this code > -------------------------------------------------------------------------------------------------- > load lena512.mat %loads lena 512 to workspace > I=lena512; % I become lena512 > fun = @dct2; %dct2 is assigned as function > J = blkproc(I,[8 8],fun); % blkproc function subblocks the image by 8-8 and usign dct2 function > figure > imshow(uint8(J)) % plot the subblocked image > title('lena512 subblocked to 8x8 using dct2 function') %title of the code > ------------------------------------------------------------------------------------------------ > but i dont know how to do step > 3. For each subblock, keep only a fixed set of 10 coefficients and set others to zero (Same set of coefficients should be kept for all subblocks). > > I also check up for this code for my solution but did not figure out how to do step 3 > > load lena512.mat; > M = lena512; > bs = [8 8] % size of the block > % % step 1 divide into blocks > szM = size(I1) > nb = ceil(szM ./ bs) % number of blocks in each dimension > C = mat2cell(M,repmat(bs(1),1,nb(1)), repmat(bs(2),1,nb(2))); > > I do not want to be rude. Saw lots of people read this thread and could not gave an answer and I update the thread. Also lots of people asking from different countries we don't have the same time zone. my doubt is if the image is not a multiple of 8 ,how will u divide the image into sub blocks 8*8?padding or wat else.is it affect reconstruction?thanks for your reply |