2 views (last 30 days)
liam xu on 23 May 2022
Commented: liam xu on 23 May 2022
have a grey image lenna512.bmp as im, were asked to do the two-dimensional DCT of all the 8 X 8 non-overlapping blocks of the image im, and merge the left-top pixel of all blocks after the DCT transformation to get a smaller image ims.
this is what I did:
B = zeros(64,64);
for i = 1:64
for j = 1:64
%Split the original image into non-overlapping 8*8blocks
%making a total of 64*64=4096
C = A((8*i-7):8*i, (8*j-7):8*j);
%Call the build-in function to perform a
%2-dimentional Fourier transform on each block
D = dct2(C);
%Fill the top left element of the
%completed block to a new matrix
B(i,j) = D(1,1);
end
end
%imwrite(uint8(B),'ims.bmp');
imshow(uint8(B));
it shows a blank image without any details, please tell me how to fix it
liam xu on 23 May 2022
sorry it's not the fourier transform it's a cosine transform

Chunru on 23 May 2022
figure; imshow(A); whos
Name Size Bytes Class Attributes A 512x512 262144 uint8 I 512x512x3 786432 uint8 cmdout 1x33 66 char
B = zeros(64,64);
for i = 1:64
for j = 1:64
%Split the original image into non-overlapping 8*8blocks
%making a total of 64*64=4096
C = A((8*i-7):8*i, (8*j-7):8*j);
%Call the build-in function to perform a
%2-dimentional Fourier transform on each block
D = dct2(double(C));
%Fill the top left element of the
%completed block to a new matrix
B(i,j) = D(1,1);
end
end
%imwrite(uint8(B),'ims.bmp');
%imshow(uint8(B));
figure; imagesc(B) liam xu on 23 May 2022
thank you
i got it, just use imshow(,[])

R2022a

### Community Treasure Hunt

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

Start Hunting!