Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Image Crop

Hello there,

I have an image that's 320 x 240 in size. I draw a rectangle area over the image that needs to be cropped. I get 4 values from the rectangle and they are,

  1. X = X-axis value from top left of rectangle.
  2. Y = Y-axis value from top left of rectangle.
  3. Width = Width of rectangle.
  4. Height = Height of rectangle.

Now what am doing is,

Rect r(X, Y, Width, Height); Mat orig_Image; Mat cropped_Image = orig_Image(r).clone();

I tried some other approaches also. But what i see is that the cropping is not 100% accurate.

It looks like the Y axis seems to be off by few pixels.

Is there a different approach to cropping?

I am working on a C++ project.

Thanks in advance.