import cv2
import numpy as np

def read_16bit_png(file_path):
    """
    Read a 16-bit PNG image and print all pixel values
    
    Parameters:
        file_path: Path to the 16-bit PNG image
    """
    # Read the image, using cv2.IMREAD_ANYDEPTH to ensure 16-bit data is read
    img = cv2.imread(file_path, cv2.IMREAD_ANYDEPTH)
    
    if img is None:
        print(f"Failed to read image: {file_path}")
        return
    
    # Check image data type
    print(f"Image data type: {img.dtype}")
    print(f"Image shape (height, width): {img.shape}")
    print(f"Pixel value range: [{np.min(img)}, {np.max(img)}]")
    print("\nPixel values:")
    
    # Iterate through all pixels and print their values
    for i in range(img.shape[0]):
        for j in range(img.shape[1]):
            print(f"({i}, {j}): {img[i, j]}", end="  ")
        print()  # New line

if __name__ == "__main__":
    import sys
    
    if len(sys.argv) != 2:
        print("Usage: python read_16bit_png.py <16-bit PNG file path>")
        sys.exit(1)
    
    file_path = sys.argv[1]
    read_16bit_png(file_path)
