如何在Matlab中为边缘检测和角点检测提供感兴趣区域(ROI)?

发布于 2024-12-18 13:38:03 字数 1489 浏览 3 评论 0原文

我有一个电影文件,我有兴趣在其中记录一个点的运动;具体来说,是圆形特征的中心。我正在尝试使用 Matlab 中的边缘检测和角点检测技术来执行此操作。

要执行此操作,如何指定视频中的感兴趣区域?次要情节是个好主意吗?

我试图使用如下的二进制蒙版来执行此操作,

hVideoSrc = vision.VideoFileReader('video.avi','ImageColorSpace', 'Intensity');
hEdge = vision.EdgeDetector('Method', 'Prewitt','ThresholdSource', 'Property','Threshold', 15/256, 'EdgeThinning', true);
hAB = vision.AlphaBlender('Operation', 'Highlight selected pixels');
WindowSize = [190 150];
hVideoOrig = vision.VideoPlayer('Name', 'Original');
hVideoOrig.Position = [10 hVideoOrig.Position(2) WindowSize];

hVideoEdges = vision.VideoPlayer('Name', 'Edges');
hVideoEdges.Position = [210 hVideoOrig.Position(2) WindowSize];

hVideoOverlay = vision.VideoPlayer('Name', 'Overlay');
hVideoOverlay.Position = [410 hVideoOrig.Position(2) WindowSize];

c = [123 123 170 170]; 
r = [160 210 210 160];
m = 480;  % height of pout image
n = 720;  % width of pout image
BW = ~poly2mask(c,r,m,n);

while ~isDone(hVideoSrc)
    dummy_frame = step(hVideoSrc) > 0.5;                % Read input video
    frame = dummy_frame-BW;
    edges = step(hEdge, frame);
    composite = step(hAB, frame, edges);        % AlphaBlender

    step(hVideoOrig, frame);                    % Display original
    step(hVideoEdges, edges);                   % Display edges
    step(hVideoOverlay, composite);             % Display edges overlayed
end
release(hVideoSrc);

但事实证明,应用于帧的蒙版仅适用于原始视频。边缘检测算法检测被二值掩模掩盖的边缘。如何永久屏蔽其他特征并执行边缘检测?

I have a movie file, in which I am interested in recording the movement of a point; center of a circular feature to be specific. I am trying to perform this using edge detection and corner detection techniques in Matlab.

To perform this, how do I specify a region of interest in the video? Is subplot a good idea?

I was trying to perform this using the binary masks as below,

hVideoSrc = vision.VideoFileReader('video.avi','ImageColorSpace', 'Intensity');
hEdge = vision.EdgeDetector('Method', 'Prewitt','ThresholdSource', 'Property','Threshold', 15/256, 'EdgeThinning', true);
hAB = vision.AlphaBlender('Operation', 'Highlight selected pixels');
WindowSize = [190 150];
hVideoOrig = vision.VideoPlayer('Name', 'Original');
hVideoOrig.Position = [10 hVideoOrig.Position(2) WindowSize];

hVideoEdges = vision.VideoPlayer('Name', 'Edges');
hVideoEdges.Position = [210 hVideoOrig.Position(2) WindowSize];

hVideoOverlay = vision.VideoPlayer('Name', 'Overlay');
hVideoOverlay.Position = [410 hVideoOrig.Position(2) WindowSize];

c = [123 123 170 170]; 
r = [160 210 210 160];
m = 480;  % height of pout image
n = 720;  % width of pout image
BW = ~poly2mask(c,r,m,n);

while ~isDone(hVideoSrc)
    dummy_frame = step(hVideoSrc) > 0.5;                % Read input video
    frame = dummy_frame-BW;
    edges = step(hEdge, frame);
    composite = step(hAB, frame, edges);        % AlphaBlender

    step(hVideoOrig, frame);                    % Display original
    step(hVideoEdges, edges);                   % Display edges
    step(hVideoOverlay, composite);             % Display edges overlayed
end
release(hVideoSrc);

but it turns out that the mask applied on frame is good only for the original video. The edge detection algorithm detects the edges those are masked by binary mask. How can I mask other features permanently and perform edge detection?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最初的梦 2024-12-25 13:38:03

你是这个意思吗?

BW = poly2mask(c,r,m,n);
frame = dummy_frame .* BW;

Is this what you mean?

BW = poly2mask(c,r,m,n);
frame = dummy_frame .* BW;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文