A new algorithm that uses image Jitter to obtain the contour of an object

Source: Internet
Author: User

In the differential test, we found that the arm with fast motion is good, but the effect is not good for the body with little motion. When we accidentally swing the camera, we found that it can obtain the contour after the difference, further, if the camera does not move and the image is jittery, that is, the entire image is moved up to the left, so that the contour can be obtained in the difference, therefore, we have implemented this in opencv5.Algorithm. The test results are good.

Its advantage is a novel, simple, and computation method, because it does not need to calculate any gradient. If you use some well-intentioned and Sobel operators, it will be much slower, its disadvantage is that it introduces interference from other objects.

In fact, the greater significance is that in a static scenario, when we need to split those static objects, we may use this method to easily obtain the contour.

The algorithm is as follows:

// Use the frame difference method to obtain the contour
Int humanmotion: getcontour (iplimage * gray, iplimage * pre_grey)
{
Cvmat;
Cvmat * temp = cvgetmat (pre_grey, & mat, 0, 2 );

Int shift_x = 1;
Int shift_y = 1;

For (INT x = 0; x <mat. rows-shift_x; X ++)
{
For (INT y = 0; y <mat. step-shift_x; y ++)
{
Int value = mat. Step * x + y;
Int value2 = mat. Step * (x + shift_x) + Y + shift_y;
Mat. Data. PTR [value] = mat. Data. PTR [value2];
}
}

Cvabsdiff (Gray, pre_grey, abs_image );
Cvthreshold (abs_image, abs_image, 20,255, cv_thresh_binary );
Return 0;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.