gusucode.com > 红外图像增强及目标检测演示界面matlab源码程序 > code/TrousTargetDetection.m
function TrousTargetDetection X=U_Open; if (X==0) errordlg('图像打开失败');break; end label=inputdlg('若图像为暗目标图像,请输入0,否则输入1','图像类型标志',1,{'0'}); label=str2num(char(label)); if(isrgb(X)) X=rgb2gray(X); end if(label==1) [row col]=size(X); X=im2double(X(20:row-20,30:col-30)); elseif(label==0) X=im2double(X); X=max(X(:))-X; else errordlg('输入图像类型错误');break; end tic %ImageEnhance C=TrousImageEnhance(X,8); %ImSegmentation [SgIm,x1,y1]=regionGrowing(C,4); [row col]=size(X); figure subplot(1,3,1); imshow(X); title('原图像'); hold on plot([y1-10 y1-10],[x1-10 x1+10 ]); plot([y1+10 y1+10],[x1-10 x1+10 ]); plot([y1-10 y1+10],[x1-10 x1-10]); plot([y1-10 y1+10],[x1+10 x1+10]); hold off subplot(1,3,2); imshow(C); title('增强图像'); subplot(1,3,3); imshow(SgIm); title('目标检测结果'); msgbox(['所用时间',num2str(toc),'秒']);