資源描述:
《彩色圖像轉(zhuǎn)灰度圖像》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、彩色圖像轉(zhuǎn)灰度圖像L=imread('i:1.jpg')L=double(L);Xrgb=0.2990*L(:,:,1)+0.5870*L(:,:,2)+0.1140*L(:,:,3);NbColors=255;X=wcodemat(Xrgb,NbColors);map1=gray(NbColors);image(X);colormap(map1);title('原圖像的灰度圖');小波壓縮-低頻信息保留壓縮方式L=imread('i:1.jpg')L=double(L);Xrgb=0.2990*L(:,:,1)+0.5870*L(:,:,2)+0.
2、1140*L(:,:,3);NbColors=255;X=wcodemat(Xrgb,NbColors);map1=gray(NbColors);image(X);colormap(map1);title('原圖像的灰度圖');axissquare;disp('灰度圖像X的大小');whos('X')[c,s]=wavedec2(X,2,'bior3.7');ca1=appcoef2(c,s,'bior3.7',1);ch1=detcoef2('h',c,s,1);%水平方向cv1=detcoef2('v',c,s,1);%垂直方向cd1=detcoef
3、2('d',c,s,1);%斜線方向a1=wrcoef2('a',c,s,'bior3.7',1);h1=wrcoef2('h',c,s,'bior3.7',1);v1=wrcoef2('v',c,s,'bior3.7',1);d1=wrcoef2('d',c,s,'bior3.7',1);%各頻率成分重構(gòu)c1=[a1,h1;v1,d1];image(c1);colormap(gray);axissquare;title('分解后低頻和高頻信息');ca1=appcoef2(c,s,'bior3.7',1);ca1=wcodemat(ca1,440,'m
4、at',0);ca1=0.5*ca1;disp('第一次壓縮后圖像的大小為:');image(ca1);colormap(gray);%colormap(map);axissquare;title('第一次壓縮圖像');whos('ca1')ca2=appcoef2(c,s,'bior3.7',2);ca2=0.25*ca2;image(ca2);colormap(gray);%colormap(map);axissquare;title('第二次壓縮圖像');disp('第二次壓縮后圖像大小為:');whos('ca2')灰度圖像X的大小NameSiz
5、eBytesClassX150x125150000doublearrayGrandtotalis18750elementsusing150000bytes第一次壓縮后圖像的大小為:NameSizeBytesClassca182x7045920doublearrayGrandtotalis5740elementsusing45920bytes第二次壓縮后圖像大小為:NameSizeBytesClassca248x4216128doublearrayGrandtotalis2016elementsusing16128bytes二維小波壓縮H=imread('
6、i:1.jpg')H=double(H);Grgb=0.2990*H(:,:,1)+0.5870*H(:,:,2)+0.1140*H(:,:,3);NbColors=255;G=wcodemat(Grgb,NbColors);map2=gray(NbColors);figure(4);image(G);colormap(map2);title('原圖像的灰度圖');%轉(zhuǎn)換成為灰度級(jí)索引圖像[CA1,CH1,CV1,CD1]=dwt2(G,'bior3.7');%從分解系數(shù)中提取近似和細(xì)節(jié)[CA1,CH1,CV1,CD1]=dwt2(G,'bior3.7
7、');A1=upcoef2('a',CA1,'bior3.7',1);H1=upcoef2('h',CH1,'bior3.7',1);V1=upcoef2('v',CV1,'bior3.7',1);D1=upcoef2('d',CD1,'bior3.7',1);%顯示近似和細(xì)節(jié)%figure('name','近似分量A1');colormap(map2);subplot(2,2,1);image(wcodemat(A1,192));title('近似A1');subplot(2,2,2);image(wcodemat(H1,192));title('水平
8、細(xì)節(jié)H1');subplot(2,2,3);image(wcodemat(V1,