Phụ lục
314
im_b=idct2(im_dct_b);
im=zeros(size(red,1),size(red,2),3);
im(:,:,1)=im_r;
im(:,:,2)=im_g;
im(:,:,3)=im_b;
imwrite(im, outfile);
figure('Name','Output image');
imshow(im);
return;
end
end
if isgray(a)
dvalue=double(a);
if isa(a,'uint8')
img_dct=dct2(dvalue);
img_pow=(img_dct).^2;
img_pow=img_pow(:);
[B,index]=sort(img_pow);
B=flipud(B);
index=flipud(index);
compressed_dct=zeros(size(dvalue));
for ii=1:coeff
compressed_dct(index(ii))=img_dct(index(ii));
end
im=idct2(compressed_dct);
im=uint8(im);
end
if isa(a,'uint16')
img_dct=dct2(dvalue);
img_pow=(img_dct).^2;
img_pow=img_pow(:);
[B,index]=sort(img_pow);
B=flipud(B);
index=flipud(index);
compressed_dct=zeros(size(dvalue));
for ii=1:coeff
compressed_dct(index(ii))=img_dct(index(ii));
end
im=idct2(compressed_dct);
im=uint16(im);