drawContours
will work in-place on the image
. Just make a copy of your image
prior to drawing the contours onto it:
contour_image = copy.deepcopy(image)
contours, _ = cv2.findContours(canny, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
cv2.drawContours(contour_image, contours, -1, (0, 255, 0), 3)
cv2.imwrite('contours_on_image.png', contour_image)
Your image
will remain untouched, thus you are cropping the original pixels.