how to create a video after an edge detection for loop
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi all!
Hopefully you can help, I'm having trouble getting this code to work. My aim is to apply edge detection to a video of cells (this part works and I am happy with it) and then have the frames of the resulting edge detection become a new .avi video in itself (that I can play just like the previous .avi file). I have tried a number of methods outside the for loop I created for the edge detection but none of it seems to work. The code is below:
function Vid_Edge_Detection_flourescent
v = VideoReader('VID00126.AVI');
n = v.NumFrames;
for i = 1:n
I0 = read(v,i);
I1 = im2bw(I0,graythresh(I0)-0.03);
I2 = bwareaopen(I1,50);
I3 = edge(I2);
II = imfuse(I0,I3);
imshow(II,'initialmagnification','fit')
pause(0.1)
end
open(v);
w = VideoWriter('Flourescent00126.AVI');
for k = 1:20
surf(sin(2*pi*k/20)*Z,Z)
frame = getframe(gcf);
writeVideo(v,frame);
end
close(v);
If anyone can help that would be amazing! I cant share the .avi as it is above 5mb but the general principle goes. Id like to have a new resulting avi file that the edge detection function has changed. Thanks in advance!
댓글 수: 0
채택된 답변
Image Analyst
2020년 7월 4일
You're not writing the edge image out, either to a saved image file or the video. See my attached demos -- they show you how to do it. In particular the movie_Canny makes a movie of the edges.
댓글 수: 4
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!