Reputation: 1254
I am working on the problem of segmentation in videos. The user segments the first frame correctly (using grabcut here) and I generate a mask from here. The black pixels all correspond to the background and white pixels correspond to foreground. In all subsequent frame I want to shift these white pixels according to some rule. That is I want to shift all the white pixels by some amount. Is there anyway ( a function probably?) that can help me do this shifting?
As in, a brute-force way will be to visit every pixel and if it white, make the pixel to the (right/left) of it to move by whatever amount I want to shift the mask. I was wondering if there is a smarter way to do this?
Upvotes: 0
Views: 734
Reputation: 7166
So you binarized the image by a threshold, resulting in back- and foreground pixels (like canny)?
You could apply a contour on the foreground pixels. Each contour is stored as a vector of points, therefore you can apply/move a contour on the next frame.
For finding contours in an Image use findContours.
Upvotes: 1