How do I crop an image in opencv and python based on percentage

Viewed 4701

I want to take an image and crop it by 75% from the center of the original image. To be honest I'm at a bit of a loss on it. I had thought about getting the original image size

height, width = image.shape

getting a percentage value and cropping:

cropped_y_start = int((height * 0.75))
cropped_y_end = int((height * 0.25))
cropped_x_start = int((width * 0.75))
cropped_x_end = int((width * 0.25))

print cropped_x_start
print cropped_x_end

crop_img = image[cropped_y_start:cropped_y_end, cropped_x_start:cropped_x_end]

There are multiple problems with this but the main one being its not based off the center of the image. Any advice on this would be much appreciated.

1 Answers
Related