Shyam Joe
Junior Member level 3
- Joined
- Aug 21, 2013
- Messages
- 28
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 322
I need a MATLAB code to compress a 256X256 image into 16X16 image and convert it into binary image. I have obtained the following code from the net. Whether any modifications in the code can generate a 16X16 image?? If not pls suggest some other code
Code:
clc
close all
im=imread('cameraman.tif');
im = double(im)/255;
subplot(2,2,1)
imshow(im)
title('Original image');
img_dct=dct2(im);
img_pow=(img_dct).^2;
img_pow=img_pow(:);
[B,index]=sort(img_pow);%no zig-zag
B=flipud(B);
index=flipud(index);
compressed_dct=zeros(size(im));
coeff = 20000;% maybe change the value
for k=1:coeff
compressed_dct(index(k))=img_dct(index(k));
end
im_dct=idct2(compressed_dct);
im_bin=im2bw(im_dct);
subplot(2,2,2)
imshow(im_dct)
title('DCT Compress Image');
subplot(2,2,3)
imshow(im_bin)
title('DCT Binary Image');
Last edited by a moderator: