フィルターのクリア

Plot a line over every frame in a for loop

6 ビュー (過去 30 日間)
Tala Hed
Tala Hed 2018 年 3 月 28 日
コメント済み: Tala Hed 2018 年 3 月 28 日
Experts,
I extracted the frames from a video and detected the edges of the moving object. Then drew a line that passes from the very top pixel of the boundary. I want the line to appear on every frame,However, the line only appears for the last frame.In addition, I need to label the y value of the line as well. Can you please help me. Here is the code and the image. I added the yellow arrow on the image with powerpoint to be clear. The left frame is missing the line and the image in the right is the last frame which has a line.
if true
for i=1:10
FileName=strcat(num2str(i),'.jpg');
Im=imread(FileName);
Im=imcrop(Im,[600 100 500 500]);
Im = im2double(Im);
Im=im2bw(Im,0.8);
Im = edge(Im,'Sobel');
imshow(Im)
[y, x] = find(Im);
H(w)=min(y);
w=w+1;
line([0 length(Im)], [min(y) min(y)])
end
end

採用された回答

Kai Domhardt
Kai Domhardt 2018 年 3 月 28 日
編集済み: Kai Domhardt 2018 年 3 月 28 日
You need to a pause inbetween frames, before the next imshow(Im) executes.
Adding
pause(0.1)
as the final line inside your for-loop will solve your problem and display every frame for 0.1 seconds.
  3 件のコメント
Kai Domhardt
Kai Domhardt 2018 年 3 月 28 日
You could do something like
font_size = 14;
text(0, font_size, ['Height: ' num2str(min(y))], 'Color', 'white','FontSize',font_size)
Tala Hed
Tala Hed 2018 年 3 月 28 日
Perfect . Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSubplots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by