import sys
import cv2
import numpy as np

def remove_negatives(input_path, output_path):
    try:
        # Load the input image
        input_image = cv2.imread(input_path)

        if input_image is None:
            raise Exception("Error: Unable to read input image.")

        # Convert the image to grayscale (optional, depending on your specific needs)
        grayscale_image = cv2.cvtColor(input_image, cv2.COLOR_BGR2GRAY)

        # Remove negative values (set all negative pixels to zero)
        positive_image = np.maximum(grayscale_image, 0)

        # Save the processed image
        cv2.imwrite(output_path, positive_image)

        print(f"Negative values removed. Output saved as {output_path}")

    except Exception as e:
        print(f"An error occurred: {str(e)}")

if __name__ == "__main__":
    if len(sys.argv) != 3:
        print("Usage: python remove_negatives.py input_image.jpg output_image.jpg")
    else:
        input_image_path = sys.argv[1]
        output_image_pa