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.
|
|
0
|
|
|
|
Reply
|
yigit
|
6/4/2010 10:36:04 AM |
|
can anyone know a solution about this ?
|
|
0
|
|
|
|
Reply
|
yigit
|
6/4/2010 1:13:04 PM
|
|
"yigit ozsahin" <yigitozsahin@gmail.com> wrote in message
news:huakuk$7lh$1@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@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
|
|
0
|
|
|
|
Reply
|
Steven
|
6/4/2010 1:21:48 PM
|
|
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.
|
|
0
|
|
|
|
Reply
|
yigit
|
6/4/2010 7:59:23 PM
|
|
On Jun 5, 12:59=A0am, "yigit ozsahin" <yigitozsa...@gmail.com> wrote:
> I wrote this code
> -------------------------------------------------------------------------=
-------------------------
> load lena512.mat %loads lena 512 to workspace
> I=3Dlena512; =A0% I become lena512
> fun =3D @dct2; %dct2 is assigned as function
> J =3D 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. =A0 =A0 =A0For each subblock, keep only a fixed set of 10 coefficients=
and set others to zero (Same set of coefficients should be kept for all su=
bblocks).
>
> I also check up for this code for my solution but did not figure out how =
to do step 3
>
> load lena512.mat;
> M =3D lena512;
> =A0 =A0bs =3D [8 8] % size of the block
> % % step 1 divide into blocks
> =A0 =A0szM =3D size(I1)
> =A0 =A0nb =3D ceil(szM ./ bs) % number of blocks in each dimension
> =A0 =A0C =3D 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 n=
ot 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
|
|
0
|
|
|
|
Reply
|
Leena
|
6/5/2010 5:10:48 AM
|
|
Leena Silvoster wrote:
> On Jun 5, 12:59 am, "yigit ozsahin" <yigitozsa...@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).
MaskMatrix = zeros(8,8);
MaskMatrix(round(linspace(1,64,10))) = 1;
fun = @(B) dct2(B) .* MaskMatrix;
Why _those_ 10 coefficients, linspace(1,64,10), instead of something
else? Only because they together span the 8x8 space. If you really
wanted, you could do (64 Choose 10) different sets of coefficients and
find the set that reconstructs the best for your test image; the best
set would probably be different for other images. (64 Choose 10) is only
151473214816 possibilities: if you start now, you could be finished...
ummm, before some New Years or other.
|
|
0
|
|
|
|
Reply
|
Walter
|
6/5/2010 5:52:42 AM
|
|
|
5 Replies
438 Views
(page loaded in 0.113 seconds)
|