OpenCV cut image via ROI clip image based on area of interest

Source: Internet
Author: User

 

When we use OPENCV, we sometimes need to trim existing images, such as just a small window of content, so we can get through the area of interest in OPENCV The Interest (ROI) is very easy to implement, the operation is very simple, first build a new iplimage picture, size for you need to cut out the size, and then set up a cvrect variable of that size, to set the ROI of the original image range, and then copy the original image to a new picture , you get what we need, and finally don't forget to restore the ROI of the original image, see the code below:

 

 iplimage *img = Cvloadimage (  " image.jpg  , 0  ); Cvrect ROI  = cvrect (1 , 1 , 50 , 50  ); Iplimage  *newimg = Cvcreateimage (Cvsize (Roi.width, Roi.height), img->depth, Img->nchannels); Cvsetimageroi (IMG, ROI); Cvcopy (Newimg, IMG); Cvresetimageroi (IMG);  

 

OpenCV cut image via ROI crop a picture by interest area

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.