0

我正在从事一个图像处理项目,该项目基于仅相位重建的重要性。有关更多信息,您可以在https://dsp.stackexchange.com/questions/16462/how-moving-part-pixel-intensity-values-of-video-frames-becomes-dominant-compared中阅读 geometrikal 给出的答案

项目有 2 个部分。

  1. 从道路交通视频中检测移动物体(请通过(步骤1)单击播放按钮然后(步骤2)右键单击视频然后(步骤3)单击另存为选项下载1.47 MB​​的视频)

  2. 跟踪视频中的任何单个移动对象。

现在,我在项目的第一部分非常成功。它的算法是

算法 1 建议的方法

要求:从视频中提取的输入图像序列 I(x, y, n)(其中 x 和 y 是图像尺寸,n 表示视频中的帧数)。

结果:每帧运动物体的分割掩码

  1. 对于输入视频中的每一帧,执行第 2 步,将第 2 步结果附加到结果数组 'I(x, y, n)'</p>

  2. 使用 2D 高斯滤波器平滑当前帧

  3. 使用(Eq.4.1)对整个序列 I(x, y, n) 执行 3D FFT

  4. 使用 3D DFT 的实部和虚部计算相位谱

  5. 使用 (Eq.4.2) 计算重构序列 α(x, y, n)

  6. 对于输入视频中的每一帧,执行步骤 7 到步骤 10 以获得每一帧的分割掩码,并将步骤 10 附加到生成的分割掩码数组 BW(x,y,n)'</p>

  7. 使用平均滤波器平滑重建的 Î(x, y, n) 帧。

  8. 计算当前帧的平均值

  9. 以平均值为阈值将当前帧转换为二值图像

  10. 进行形态学处理,即填充和闭合,得到当前帧运动物体的分割掩码

  11. 结束算法。

使用上述算法,我可以从视频中找到所有移动对象。现在,我想转到第二部分,即对视频中的任何单个移动对象进行跟踪。

在此处输入图像描述

如图所示,我已经达到了第一列所示的结果。我只达到了第一列的结果。但我的目标是跟踪单个车辆,如图第二列所示。(我使用 Photoshop 制作了第二列中显示的结果)

那么有人可以帮助我吗?

 tic
clc;
clear all;
close all;
  
%read video file
video = VideoReader('D:\dvd\Matlab code\test videos\5.mp4');

T= video.NumberOfFrames  ;           %number of frames%

frameHeight = video.Height;          %frame height

frameWidth = video.Width ;           %frameWidth

get(video);                          %return graphics properties of video


i=1;

for t=300:15:550  %select frames between 300 to 550 with interval of 15 from the video  
    frame_x(:,:,:,i)= read(video, t); 
    frame_y=frame_x(:,:,:,i);

    %figure,
    %imshow(f1),title(['test frames :' num2str(i)]);
    frame_z=rgb2gray(frame_y);                 %convert each colour frame into gray
    
    frame_m(:,:,:,i)=frame_y; %Store colour frames in the frame_m array 
     
    %Perform Gaussian Filtering
    h1=(1/8)*(1/8)*[1 3 3 1]'*[1 3 3 1]  ;   % 4*4 Gaussian Kernel  
    convn=conv2(frame_z,h1,'same');
        
    g1=uint8(convn);
    
                    
    Filtered_Image_Array(:,:,i)=g1; %Store filtered images into an array
    i=i+1;
end

%Apply 3-D Fourier Transform on video sequences
f_transform=fftn(Filtered_Image_Array);

%Compute phase spectrum array from f_transform
phase_spectrum_array =exp(1j*angle(f_transform));

%Apply 3-D Inverse Fourier Transform on phase spectrum array and
%reconstruct the frames
reconstructed_frame_array=(ifftn(phase_spectrum_array));


k=i;

i=1;
for t=1:k-1
    
    %Smooth the reconstructed frame of Î(x, y, n) using the averaging filter.
    Reconstructed_frame_magnitude=abs(reconstructed_frame_array(:,:,t));  
    H = fspecial('disk',4);
    circular_avg(:,:,t) = imfilter(Reconstructed_frame_magnitude,H);
        
    
    %Convert the current frame into binary image using mean value as the threshold
    mean_value=mean2(circular_avg(:,:,t));  
    binary_frame = im2bw(circular_avg(:,:,t),1.6*mean_value);
    
    
    %Perform Morphological operations
    se = strel('square',3);
    morphological_closing = imclose(binary_frame,se); 
    morphological_closing=imclearborder(morphological_closing); %clear noise present at the borders of the frames
    
    
    %Superimpose segmented masks on it's respective frames to obtain moving
    %objects
    moving_object_frame = frame_m(:,:,:,i);
    moving_object_frame(morphological_closing) = 255;  
    figure,
    imshow(moving_object_frame,[]), title(['Moving objects in Frame :' num2str(i)]);
    
 i=i+1;
end
toc
4

1 回答 1

0

确定要跟踪的对象后,实施卡尔曼滤波器,您将获得所需的跟踪。

那里有相当多的资源,但如果你想手工完成,我建议你使用 YouTube 上 StudentDave 的解释,它非常好。https://www.youtube.com/watch?v=FkCT_LV9Syk

于 2015-05-27T20:04:58.320 回答