0

I ve an image which has 6 images within it..I ve the task of cropping the 6 images out of this image..

Currently I follow this procedure..
1. Save copy of original image
2. Crop the image to get first image using any tool(Picasa)
3. Save the cropped image as image 1
4. Open the original to crop for image 2
5. Repeat this 6 times

Is there a way in which I can extract out all the 6 images in one go? Multi-cropping?

tss
  • 111
  • 1
  • 6
  • If this question has been successfully answered, consider selecting the official answer by clicking on the checkbox near it. If not, consider adding your own answer. – karlphillip Jun 05 '12 at 23:29

2 Answers2

1

Yes, it's possible. You need to get familiarized with the ROI (Region of Interest) concept.

This C example shows how to set a ROI in an image. Basically it sets a ROI in a frame from the camera, creates a new image from it, does some processing (invert colors) in the image and then copies the image back to the original frame for display.

This Python example also shows how to work with ROIs.

Community
  • 1
  • 1
karlphillip
  • 92,053
  • 36
  • 243
  • 426
0

From the OP description, it sounds like the OP just wants to automated way to crop an image into 6 pieces.

Google for "irfanview batch crop" or "ImageMagick batch crop"

If a more complex cropping logic/procedure is needed, then gfx library of the OP's language of choice should have a cropping function that they can code.

OpenCV would be an overkill for this task.

if OP insist on using OpenCV, then set the ROI

Mat image = imread("src_image_path"); Rect roi = Rect(x, y, w, h); Mat image_roi = image(roi);

imwrite("dest_image_path", image_roi);

an phu
  • 1,823
  • 1
  • 16
  • 10