What is the difference between cropping an image and applying a ROI (region of interest) on the image
EDIT:
Having a base image (640x640
) I want to know if applying a rectangular white shape mask of (100x100), in another words, a ROI is more time consuming compared to cropping the image in the same rectangular shape (100x100).
What I consider as being a ROI
mask = np.zeros_like(original_image)
shape = np.array([[a,b,c,d]])
cv2.fillPoly(mask, shape, (255,255,255))
cv2.bitwise_and(original_image, mask)
The way of cropping
cropped = original_image[x:y, z:t]
I want to apply a function (e.g transform to grayscale) or apply a color filter on the image.
I think that doing so on the ROIed image will be more time consuming as there are many more pixels (the resulting image has the same dimensions as the original one (640x640)).
On the other hand, applying some function on the cropped image will take less time compared to the latter.
The question is: wouldn't the operation of cropping the image compensate the time needed to compute the rest of the 640x640
- 100x100
pixels?
Hope I was clear enough. Thanks in advance
ah, alright, so it's cropping vs. masking, sorry, missed that.
but again, sorry to say so, its one of those cases, where you have to try on your own and measure.
Hi, I did measure, and the result is obviously :
This was the result of using
timeit
library inpython
, with10000
iterations. The reason why I've asked this question is because I know the mask type operation takes more time related to crop, so I wanted to find if there is any way I can crop irregular shapes without using masks.not directly. if your "irregular shape" only covers part of the image, you can still crop to the bounding box of that, and mask out the unwanted parts of it
Could you please provide me more details? A link eventually?