Êý×ÖͼÏñ´¦ÀíʵÑ鱨¸æ(È«´ð°¸)..

ʵÑéÁù ͼÏñ´¦Àíʵ¼ÊÓ¦ÓÃ

Ò»¡¢ÊµÑéÄ¿µÄ

1¡¢ÊìϤ²¢ÕÆÎÕMATLABͼÏñ´¦Àí¹¤¾ßÏäµÄʹÓã» 2¡¢Àí½â²¢ÕÆÎÕ³£ÓõÄͼÏñ´¦Àí¼¼Êõ¡£ ¶þ¡¢ÊµÑé»·¾³

MATLAB 6.5ÒÔÉÏ°æ±¾¡¢WIN XP»òWIN2000¼ÆËã»ú Èý¡¢ÊµÑéÄÚÈÝ

µ÷ÊÔÔËÐÐÏÂÁгÌÐò,·ÖÎö³ÌÐò,¶ÔÿÌõÓï¾ä¸ø³ö×¢ÊÍ,²¢ÏÔʾ×îÖÕÖ´Ðнá¹û¡£×ܽáË㷨˼Ïë¼°ÓÅȱµã.

I=imread('Car.jpg'); [y,x,z]=size(I); myI=double(I);

%%%%%%%%%%% RGB to HSI %%%%%%%% tic

%%%%%%%% Y ·½Ïò %%%%%%%%%% Blue_y=zeros(y,1); for i=1:y for j=1:x

if((myI(i,j,1)<=30)&&((myI(i,j,2)<=62)&&(myI(i,j,2)>=51))&&((myI(i,j,3)<=142)&&(myI(i,j,3)>=119))) % À¶É«RGBµÄ»Ò¶È·¶Î§

Blue_y(i,1)= Blue_y(i,1)+1; end end end

[temp MaxY]=max(Blue_y); % Y·½Ïò³µÅÆÇøÓòÈ·¶¨ PY1=MaxY;

while ((Blue_y(PY1,1)>=5)&&(PY1>1)) PY1=PY1-1; end PY2=MaxY;

while ((Blue_y(PY2,1)>=5)&&(PY2

IY=I(PY1:PY2,:,:);

%%%%%%%% X ·½Ïò %%%%%%%%%% Blue_x=zeros(1,x); for j=1:x for i=PY1:PY2

if((myI(i,j,1)<=30)&&((myI(i,j,2)<=62)&&(myI(i,j,2)>=51))&&((myI(i,j,3)<=142)&&(myI(i,j,3)>=119)))

Blue_x(1,j)= Blue_x(1,j)+1; end end end PX1=1;

while ((Blue_x(1,PX1)<3)&&(PX1

while ((Blue_x(1,PX2)<3)&&(PX2>PX1)) PX2=PX2-1; end

PX1=PX1-2; % ¶Ô³µÅÆÇøÓòµÄÐÞÕý PX2=PX2+2;

Plate=I(PY1:PY2,PX1-2:PX2,:); t=toc % ¶ÁÈ¡¼Æʱ

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% figure,imshow(I); figure,plot(Blue_y);grid figure,plot(Blue_x);grid figure,imshow(IY);

Ìí¼Ó×¢Êͺ͸ÄÕýºóµÄ³ÌÐò£º

I=imread('f:\\Car.jpg');%¶ÁȡͼƬ [y,x,z]=size(I);%¸ø¶¨Í¼Æ¬´óС myI=double(I);%·µ»ØË«¾«¶ÈÖµ

%%%%%%%%%%% RGB to HSI %%%%%%%% tic %¼Æʱ¿ªÊ¼

%%%%%%%% Y ·½Ïò %%%%%%%%%% Blue_y=zeros(y,1);%Ò»ÁÐÈ«Áã¾ØÕó for i=1:y%¸ø¶¨iµÄ·¶Î§ for j=1:x%¸ø¶¨jµÄ·¶Î§

if((myI(i,j,1)<=30)&&((myI(i,j,2)<=62)&&(myI(i,j,2)>=51))&&((myI(i,j,3

)<=142)&&(myI(i,j,3)>=119))) % À¶É«RGBµÄ»Ò¶È·¶Î§

Blue_y(i,1)= Blue_y(i,1)+1; % y¾ØÕó¼ÓÒ» end end end

[temp MaxY]=max(Blue_y); % Y·½Ïò³µÅÆÇøÓòÈ·¶¨ PY1=MaxY;%y¾ØÕóµÄ×î´óÔªËØ

while ((Blue_y(PY1,1)>=5)&&(PY1>1))% È·¶¨À¶É«RGB Blue_yËùÔÚλÖÃ

PY1=PY1-1; %¶Ô³µÅÆÇøÓòµÄÐÞÕý£¬ÏòÉϵ÷Õû end

PY2=MaxY; %y¾ØÕóµÄ×î´óÔªËØ

while ((Blue_y(PY2,1)>=5)&&(PY2

PY2=PY2+1; %¶Ô³µÅÆÇøÓòµÄÐÞÕýÏòϵ÷Õû end

IY=I(PY1:PY2,:,:);%Ðеķ¶Î§

%%%%%%%% X ·½Ïò %%%%%%%%%% Blue_x=zeros(1,x); %Ò»ÐÐÈ«Ò»¾ØÕó for j=1:x%¸ø¶¨jµÄÈ¡Öµ·¶Î§

for i=PY1:PY2%¸ø¶¨iµÄÈ¡Öµ·¶Î§

if((myI(i,j,1)<=30)&&((myI(i,j,2)<=62)&&(myI(i,j,2)>=51))&&((myI(i,j,3)<=142)&&(myI(i,j,3)>=119)))%µ÷ÕûIÖеķ¶Î§

Blue_x(1,j)= Blue_x(1,j)+1; % Blue_x µÄ¾ØÕó¼ÓÒ» end end end

PX1=1;%µ±PX1µÈÓÚ1ʱ

while ((Blue_x(1,PX1)<3)&&(PX1

PX1=PX1+1; %¶Ô³µÅÆÇøÓòµÄÐÞÕýÏòϵ÷Õû end

PX2=x; %µ±PX2µÈÓÚxʱ

while ((Blue_x(1,PX2)<3)&&(PX2>PX1)) %È·¶¨À¶É«RGB Blue_xµÄλÖà PX2=PX2-1; %¶Ô³µÅÆÇøÓòµÄÐÞÕýÏòϵ÷Õû end

PX1=PX1-2; % ¶Ô³µÅÆÇøÓòµÄÐÞÕý PX2=PX2+2; %¶Ô³µÅÆÇøÓòµÄÐÞÕý

Plate=I(PY1:PY2,PX1-2:PX2,:);%¾ØÕóÐÐÁеķ¶Î§ t=toc % ¶ÁÈ¡¼Æʱ

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% figure,imshow(I);%´´½¨Í¼Ïñ´°¿Ú£¬ÏÔʾͼÏñI

figure,plot(Blue_y);grid%´´½¨Í¼Ïñ´°¿Ú£¬»æÖÆBlue_yͼÏñ£¬»­³öÍø¸ñÏß figure,plot(Blue_x);grid%´´½¨Í¼Ïñ´°¿Ú£¬»æÖÆBlue_xͼÏñ£¬»­³öÍø¸ñÏß figure,imshow(Plate); %´´½¨Í¼Ïñ´°¿Ú£¬ÏÔʾͼÏñPlate t =

0.5630

ÁªÏµ¿Í·þ£º779662525#qq.com(#Ì滻Ϊ@) ËÕICP±¸20003344ºÅ-4