How to get the previous values of Edge Detection of the previous frame (video)
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi,
I successfully implemented Difference of Gaussian (DoG) Edge Detection to a Grayscale Video by applying the DoG Method frame by frame.
Now the values are stored in a Matrix named DoGvideo which is always overwritten by the next frames DoG values. In the next step i need to work with every frames DoG values but i couldnt find a method or code to get for example the DoG of the previous frame etc...
Can someone guide me to the right direction?
댓글 수: 0
답변 (1개)
Sachin Lodhi
2023년 11월 10일
Hi,
Based on my understanding, it seems that you want to work with the Difference of Gaussian (DoG) values of each frame while processing the current frame of the video.
One way to do this is to use a cell array or a 3D matrix to store the DoG values of each frame. The ‘fspecial’ function can be used to construct the logic for the DoG filter. Following that, the ‘conv2’ function can be utilized to apply the DoG filter to the image.
Here is a sample code to demonstrate the logic -
% Read the video file
v = VideoReader('your_video_file.mp4');
% Preallocate the cell array to store the DoG values / filter images
numFrames = floor(v.Duration * v.FrameRate);
DoGvideo = cell(1, numFrames);
gaussian1 = fspecial('Gaussian', 21, 10);
gaussian2 = fspecial('Gaussian', 21, 13);
dog = gaussian1 - gaussian2;
k = 1;
while hasFrame(v)
frame = readFrame(v);
frame = rgb2gray(frame); % Convert to grayscale if your video is in color
dogFilterImage = conv2(double(frame), dog, 'same');
% Store the result in the cell array
DoGvideo{k} = dogFilterImage;
k = k + 1;
end
% Work with any frames DoG filter image DoGvideo{i};
I hope this helps.
Best Regards,
Sachin
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!