Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to provide region of interest (ROI) for edge detection and corner detection in Matlab?

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?

like image 235
Sulla Avatar asked Nov 29 '11 22:11

Sulla


1 Answers

Is this what you mean?

BW = poly2mask(c,r,m,n);
frame = dummy_frame .* BW;
like image 111
Martin Thompson Avatar answered Nov 15 '22 12:11

Martin Thompson