欢迎来到天天文库
浏览记录
ID:12899174
大小:324.50 KB
页数:8页
时间:2018-07-19
《空域、频域图像增强举例》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、MATLAB图像增强程序举例1.灰度变换增强程序:%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);%把索引图像转换为灰度图像imshow(I);title('原图像');improfile%用鼠标选择一条对角线,显示线段的灰度值figure;subplot(121)plot(0:0.01:1,sqrt(0:0.01:1))axissquaretitle('平方根灰度变换函数')subplot(122)maxnum=double(max(max(I)4、));%取得二维数组最大值J=sqrt(double(I)/maxnum);%把数据类型转换成double,然后进行平方根变换%sqrt函数不支持uint8类型J=uint8(J*maxnum);%把数据类型转换成uint8类型imshow(J)title('平方根变换后的图像')3.直方图均衡化程序举例%HISTGRAMEAQUALIZATIONclc;%ClearcommandwindowI=imread('tire.tif');%readstheimageintire.tifintoIimshow(I);%displaystheintensityimageIwith255、6graylevelsfigure;%createsanewfigurewindowimhist(I);%displaysahistogramfortheintensityimageIJ=histeq(I,64);%transformstheintensityimageI,returningJanintensityfigure;%imagewith64discretelevelsimshow(J);figure;imhist(J);J=histeq(I,32);%transformstheintensityimage,returningin%Janintensityfigur6、e;%imagewith32discretelevelsimshow(J);figure;imhist(J);4.直方图规定化程序举例%HISTGRAMREGULIZATIONclc;%ClearcommandwindowI=imread('tire.tif');%readstheimageintire.tifintoIJ=histeq(I,32);%transformstheintensityimageI,returningin%Janintensityimagewith32discretelevels[counts,x]=imhist(J);%displaysahisto7、gramfortheintensityimageIQ=imread('pout.tif');%readstheimageintire.tifintoIfigure;imshow(Q);figure;imhist(Q);M=histeq(Q,counts);%transformstheintensityimageQsothatthe%histogramoftheoutputimageMapproximatelymatchescountsfigure;imshow(M);figure;imhist(M);空
3、ive.figure;imshow(J);5.bmp(587.92KB)2008-7-1808:252.直方图灰度变换%直方图灰度变换[X,map]=imread('forest.tif');I=ind2gray(X,map);%把索引图像转换为灰度图像imshow(I);title('原图像');improfile%用鼠标选择一条对角线,显示线段的灰度值figure;subplot(121)plot(0:0.01:1,sqrt(0:0.01:1))axissquaretitle('平方根灰度变换函数')subplot(122)maxnum=double(max(max(I)
4、));%取得二维数组最大值J=sqrt(double(I)/maxnum);%把数据类型转换成double,然后进行平方根变换%sqrt函数不支持uint8类型J=uint8(J*maxnum);%把数据类型转换成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.直方图规定化程序举例%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);空
此文档下载收益归作者所有