Ruben Veiga
Ruben Veiga

Reputation: 343

Cut a jpg file in C, (NOT crop)

i would like to know how can i cut a jpg file using a coordinates i want to retrieve using artoolkit and opencv, see:

Blob Detection

i want to retrieve coordinates of the white sheet and then use those coordinates to cut a jpg file I'm took before. Find this but how can this help? How to slice/cut an image into pieces

Upvotes: 0

Views: 472

Answers (1)

karlphillip
karlphillip

Reputation: 93468

If you already have the coordinates, you might want to deskew the image first:

http://nuigroup.com/?ACT=28&fid=27&aid=1892_H6eNAaign4Mrnn30Au8d

This post uses cv::warpPerspective() to achieve that effect.

The references above use the C++ interface of OpenCV, but I'm sure you are capable of converting between the two.

Second, cutting a particular area of an image is known as extracting a Region Of Interest (ROI). The general procedure is: create a CvRect to define your ROI and then call cvSetImageROI() followed by cvSaveImage() to save it on the disk.

This post shares C code to achieve this task.

Upvotes: 1

Related Questions