Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How can I resize an image from the center?\

Hello! I have a contour, and I want to resize this contour and then draw the resized contour in same image, In another words, I want to create an external contour to the existent one. To this I need to resize the contour mask. however, when I draw both I'm in trouble, because the resized one it is not centered. How can I make the resize from the image center?

 height, width = lA1innerContourmask.shape[:2]
 nwid =int( 1.5 * width)
 nh = int(1.5 * height)
 res = cv2.resize(lA1innerContourmask,(nwid, nh),0,0, interpolation = cv2.INTER_CUBIC)

# find contour of the resized

resizedcontour, hier_ = cv2.findContours(res,cv2.RETR_CCOMP,
                                        cv2.CHAIN_APPROX_SIMPLE)

cv2.drawContours(lA1innerContourmask,resizedcontour,-1,(0,0,255),1) 
outax = np.hstack([lA1innerContourmask])    
plt.imshow(outax, 'gray')
plt.show()