if (bands != 3): print("Input image is not a standard color image:", inputImage) sys.exit() W1 = round(w1 * (cols - 1)) H1 = round(h1 * (rows - 1)) W2 = round(w2 * (cols - 1)) H2 = round(h2 * (rows - 1)) # Cut out target region image1 = inputImage[H1:H2 + 1, W1:W2 + 1, :] # Change color space image2 = cv2.cvtColor(image1, cv2.COLOR_BGR2XYZ) # Illumination stretching image3 = np.copy(image2) image3[:, :, 1] = linear_stretching(image2[:, :, 1]) # Y # Convert back to BGR check_range(image3) # check range image4 = cv2.cvtColor(image3, cv2.COLOR_XYZ2BGR) check_range(image4) # check range # Copy back to outputImage outputImage = np.copy(inputImage) for i in range(H1, H2 + 1): for j in range(W1, W2 + 1): outputImage[i, j] = image4[i - H1, j - W1] # Show image cv2.imshow((sys.argv[0]).replace(".py", ""), outputImage) # Save image cv2.imwrite(name_output, outputImage)
if (bands != 3): print("Input image is not a standard color image:", inputImage) sys.exit() W1 = round(w1 * (cols - 1)) H1 = round(h1 * (rows - 1)) W2 = round(w2 * (cols - 1)) H2 = round(h2 * (rows - 1)) # Cut out target region image1 = inputImage[H1:H2 + 1, W1:W2 + 1, :] # Change color space image2 = cv2.cvtColor(image1, cv2.COLOR_BGR2Luv) # Illumination stretching image3 = np.copy(image2) image3[:, :, 0] = linear_stretching(image2[:, :, 0]) # L # Convert back to BGR check_range(image3) # check range image4 = cv2.cvtColor(image3, cv2.COLOR_Luv2BGR) check_range(image4) # check range # Copy back to outputImage outputImage = np.copy(inputImage) for i in range(H1, H2 + 1): for j in range(W1, W2 + 1): outputImage[i, j] = image4[i - H1, j - W1] # Show image cv2.imshow((sys.argv[0]).replace(".py", ""), outputImage) # Save image cv2.imwrite(name_output, outputImage)