对图像定位,边缘检测、图像增强对视频中的某个物体进行跟踪:比如说是飞机,导弹等~
附件中的 matlab代码
- clc;
- clear;
- % close all;
- %%%%%%%%%%%%%%% 读序列图像 %%%%%%%%%%%
- location = 'D:ex7';%文件夹位置
- count=2; %图像帧数
- % aviFileName = 'images2AVI.avi';
- aviObj =avifile('image1.avi');
- % aviObj =avifile('example.avi');
- %figHandle = figure;
- % 多帧循环开始
- for i=1:count
- I_origin = imread([location num2str(i) '.bmp']);
- I= I_origin;
- k=1;J2=512;J3=0;I1=0;
- %%%%%%%%%%%%%%%%%%%% 对比度增强 %%%%%%%%%%%%%%%%%%%
- T=197;%手动选阈值
- i;
- III=size(I);
- for i=1:III(1)
- % size(I)
- n=0; flag=0;
- for j=1:512
- if I(i,j) >T
- I(i,j)=255;
- else
- if k==1 % k demostrate number
- n=n+1;
- if n>15
- I1=i;
- J1=j;
- k=k+1;n=0;
- end
- end
- if k==2
- n=n+1;
- if n>15
- if J1>j&J2>j
- I2=i;
- J2=j;
- J3=J2+70;
- end
- % if J1
- % J3=j;
- % end
- I4=i;J4=j;
- n=0;
- end
- end
- % if I(i,j)<50&k==3
- % n=n+1;
- % if n>3
- %
- % I4=i;J4=j;
- % n=0;
- % end
- % end
- I(i,j)=0;
- n=n+1;
- end
- end
- end
- J33=J3-8;
- J22=J2-25;
- for j1=J22:J33
- I(I1-8,j1)=0;
- I(I4+8,j1)=0;
- end
- for i1=(I1-8):(I4+8)
- I(i1,J22)=0;
- I(i1,J33)=0;
- end
- %%%%%%%%%%%%%%%%%%%% 图像边缘检测 %%%%%%%%%%%%%%%%%%%%%
- BW3 = edge(I,'canny');
- figure,imshow(BW3);
- frame_grayImage = im2uint8(BW3);
- aviObj = addframe(aviObj,frame_grayImage );
- % hold on;
- % imshow(BW3);
- % h = getframe(figHandle);
- % aviObj = addframe(aviObj,h );
- end % 多帧循环结束
- %close(figHandle);
- aviObj=close(aviObj);
- %%%%%%%%%%%%%%%%% SAVE %%%%%%%%%%%%
-
复制代码
刚开始一帧
最后一帧
15
|
|
|
|
循环太多,影响速度.
|
|
|
|
|
直接复制粘贴即可~ 。。下载之,学习一下~
|
|
|
|
|
感谢分享!!
|
|
|
|
|
谢谢分享
|
|
|
|
|