(I am new to this whole open cv thing) My cropping method is to click a point on the image near the top left where you want the first box and the clicked point will be the starting coordinate for the rest of the cropping. (if there is an easier method you know of, i'd be grateful for ideas)
Problem: my output images are not same in clarity. I checked this using image J and the brightness/contrast analyze function. I tried to find where the reduction is coming from in the code and I think it is from imwrite but I'm not sure; I assume imwrite is messing with the metadata. I also tried using tifffile library but it did not help.
import cv2
import tifffile as tiff
image = cv2.imread('vv.tif', cv2.IMREAD_UNCHANGED)
image_copy = image.copy()
cv2.namedWindow('image')
def crop_images(x, y):
for i in range(4):
for j in range(14):
cropped_image = image[y-260+i*900:y+260+i*900, x-260+j*900:x+260+j*900]
tiff.imwrite('cropped_image_{0}.tif'.format(i*14+j), cropped_image)
def get_coordinates(event, x, y, flags, param):
if event == cv2.EVENT_LBUTTONUP:
crop_images(x, y)
cv2.imshow('image', image_copy)
cv2.setMouseCallback('image', get_coordinates)
cv2.imshow('image', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
What I want is for the 56 cropped images to have the same brightness/contrast and clarity as original. The original image is over 2Mib so this is a screenshot of it just for reference: screenshot