資源描述:
《空域、頻域圖像增強(qiáng)舉例》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫(kù)。
1、MATLAB圖像增強(qiáng)程序舉例1.灰度變換增強(qiáng)程序:%GRAYTRANSFORMclc;I=imread('pout.tif');imshow(I);J=imadjust(I,[0.30.7],[01],1);??%transformsthewaluesinthe%intensityimageItovaluesinJbylinealymappingvalues%between0.3and0.7tovaluesbetween0and1.figure;imshow(J);J=imadjust(I,[0.30.7],[01],0.5);??%ifGAMMAislessthan1,th
2、e%mappingsiweightedtowardhigher(brighter)outputvalues.figure;imshow(J);J=imadjust(I,[0.30.7],[01],1.5);??%ifGAMMAisgreaterthan%1,themappingsiweightedtowardlower(darker)outputvalues.figure;imshow(J)J=imadjust(I,[0.30.7],[01],1);??%IfTOP3、ive.figure;imshow(J);5.bmp(587.92KB)2008-7-1808:252.直方圖灰度變換%直方圖灰度變換[X,map]=imread('forest.tif');I=ind2gray(X,map);%把索引圖像轉(zhuǎn)換為灰度圖像imshow(I);title('原圖像');improfile%用鼠標(biāo)選擇一條對(duì)角線,顯示線段的灰度值figure;subplot(121)plot(0:0.01:1,sqrt(0:0.01:1))axissquaretitle('平方根灰度變換函數(shù)')subplot(122)maxnum=double(max(max(I)
4、));%取得二維數(shù)組最大值J=sqrt(double(I)/maxnum);%把數(shù)據(jù)類型轉(zhuǎn)換成double,然后進(jìn)行平方根變換%sqrt函數(shù)不支持uint8類型J=uint8(J*maxnum);%把數(shù)據(jù)類型轉(zhuǎn)換成uint8類型imshow(J)title('平方根變換后的圖像')3.直方圖均衡化程序舉例%HISTGRAMEAQUALIZATIONclc;%ClearcommandwindowI=imread('tire.tif');%readstheimageintire.tifintoIimshow(I);%displaystheintensityimageIwith25
5、6graylevelsfigure;%createsanewfigurewindowimhist(I);%displaysahistogramfortheintensityimageIJ=histeq(I,64);%transformstheintensityimageI,returningJanintensityfigure;%imagewith64discretelevelsimshow(J);figure;imhist(J);J=histeq(I,32);%transformstheintensityimage,returningin%Janintensityfigur
6、e;%imagewith32discretelevelsimshow(J);figure;imhist(J);4.直方圖規(guī)定化程序舉例%HISTGRAMREGULIZATIONclc;%ClearcommandwindowI=imread('tire.tif');%readstheimageintire.tifintoIJ=histeq(I,32);%transformstheintensityimageI,returningin%Janintensityimagewith32discretelevels[counts,x]=imhist(J);%displaysahisto
7、gramfortheintensityimageIQ=imread('pout.tif');%readstheimageintire.tifintoIfigure;imshow(Q);figure;imhist(Q);M=histeq(Q,counts);%transformstheintensityimageQsothatthe%histogramoftheoutputimageMapproximatelymatchescountsfigure;imshow(M);figure;imhist(M);空