参考论文:
https://download.csdn.net/download/zxm_jimin/10977182
原理:
查找相同帧(图片):
function [ output_args ] = sy1_2( input_args )
fileName='D:\workspace\Matlab workspace\数字图像处理\char2\char2_test\jmucorridor.avi';
obj=VideoReader(fileName);
numFrames=obj.NumberOfFrames;
f=read(obj,1);
[f,reverclass]=tofloat(f);
fs=rgb2gray(f);
f2=read(obj,10);
[f2,reverclass]=tofloat(f2);
f2s=rgb2gray(f2);
subplot(3,2,1),imshow(fs);
subplot(3,2,2),imhist(fs),ylim('auto');
g=histeq(fs,256);
figure(1);
subplot(3,2,3),imshow(g);
subplot(3,2,4),imhist(g),ylim('auto');
subplot(3,2,5),imhist(fs-g),ylim('auto');
figure(2);
%fs=imread('Fig0228(a).tif');
%f2s=imread('Fig0233(a).tif');
subplot(3,2,1),imshow(fs);
subplot(3,2,2),imshow(f2s);
k=imhist(fs);
t=imhist(f2s);
n=length(k);
n(1,:)
d=0;
for i=1:n
di=k(i)-t(i);
d=d+di;
d=d/n;
u=1/2*(d);
q=sqrt(1/2*(d-u).^2);
Tmin=u*1.1;
Tmax=u+3.8*q;
end
d(1,:)
Tmax(1,:)
Tmin(1,:)
if d>=Tmin && d<=Tmax
subplot(3,2,6),imshow(fs);title('same');
else
error('different!');
end
查找相同帧(视频):
function [ output_args ] = sy1_2( input_args )
fileName='D:\workspace\Matlab workspace\数字图像处理\char2\char2_test\bts.mp4';
%fileName='D:\workspace\Matlab workspace\数字图像处理\char2\char2_test\jmucorridor.avi';
obj=VideoReader(fileName);
numFrames=obj.NumberOfFrames;
f2=read(obj,105);
[f2,reverclass]=tofloat(f2);
% f2s=rgb2gray(f2);
% imwrite(f2,'333.jpg');
% f2=imread('333.jpg');
f2s=rgb2gray(f2);
subplot(3,2,1),imshow(f2);
subplot(3,2,2),imhist(f2s),ylim('auto');
numFrames(1,:)
h=0;
for j=1:numFrames
f=read(obj,j);
[f,reverclass]=tofloat(f);
fs=rgb2gray(f);
k=imhist(fs);
t=imhist(f2s);
n=length(k);
d=0;
for i=1:256
di=k(i)-t(i);
d=d+di;
d=d/n;
u=1/2*(d);
q=sqrt(1/2*(d-u).^2);
Tmin=u*1.1;
Tmax=u+3.8*q;
end
d(1,:)
Tmax(1,:)
Tmin(1,:)
h=h+1;
h(1,:)
if d>=Tmin && d<=Tmax
subplot(3,2,3),imshow(fs);title(j);
break;
end
end
% function [ output_args ] = sy1_2( input_args )
% fileName='D:\workspace\Matlab workspace\数字图像处理\char2\char2_test\bts.mp4';
% obj=VideoReader(fileName);
% numFrames=obj.NumberOfFrames;
% f=read(obj,20);
% [f,reverclass]=tofloat(f);
%
% fs=rgb2gray(f);
%
% f2=read(obj,200);
% [f2,reverclass]=tofloat(f2);
%
% f2s=rgb2gray(f2);
% subplot(3,2,1),imshow(fs);
% subplot(3,2,2),imshow(f2s);
% k=imhist(fs);
% t=imhist(f2s);
% n=length(k);
% n(1,:)
% d=0;
% for i=1:n
% di=k(i)-t(i);
% d=d+di;
%
% d=d/n;
% u=1/2*(d);
% q=sqrt(1/2*(d-u).^2);
% Tmin=u*11;
% Tmax=u+3.8*q;
% end
% d(1,:)
% Tmax(1,:)
% Tmin(1,:)
% if d>=Tmin && d<=Tmax
% subplot(3,2,3),imshow(fs);title('same');
% else
% error('different!');
% end
本文为原创。
转载请注明出处。