Cho em hỏi chương trình bên dưới dùng để nén ảnh từ màu sang đen trắng,bây giờ em muốn nén ảnh màu vẫn ra ảnh màu thì phải sửa đoạn code như thế nào.Nếu có thể các anh có thể ghi chú thích từng lệnh được hông?
Em xin cảm ơn
Em xin cảm ơn
Code:
dvalue=imread('map.bmp');
dvalue = double(dvalue)/255;
dvalue = rgb2gray(dvalue);
img_dct=dct2(dvalue);
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(dvalue));
coeff = 20000;% maybe change the value
for k=1:coeff
compressed_dct(index(k))=img_dct(index(k));
end
im=idct2(compressed_dct);
imwrite(im, 'maptemp2.bmp')

Comment