Student Name: Kelvin Huang
The images from the Prokudin-Gorskii collection are read into the program using skimage.io.imread()
. Since each image in the collection is a composite of three separate black-and-white images representing the blue, green, and red channels, the program first splits the image into three parts, each corresponding to one of the color channels.
The split is done by calculating the height of the image, dividing it into three equal sections, and assigning each section to the respective color channel (B, G, R).
After splitting the image into channels, the edges of each channel are cropped to remove any misalignment or noise that may exist at the borders. This is done using the crop_image()
function, which crops a specified percentage of the edges (10% in this case) from all sides of the image.
The core of this project is the alignment of the color channels to create a properly registered color image. Misalignments between the three channels can occur due to the manual capture of the original photographs.
To align the images, a multi-resolution (pyramid) approach is used. The images are rescaled at different scales (12.5%, 25%, 50%, 100%) using skimage.transform.rescale()
. At each scale, the best displacement between the green and red channels, and the green and blue channels, is found using the align_l2_norm()
function. This function shifts the images over a range of displacements, computes the L2 norm between the shifted image and the reference image, and returns the displacement with the lowest error.
After finding the optimal displacements for both the red-to-green and blue-to-green alignments, these displacements are applied using np.roll()
, which shifts the red and blue channels accordingly.
The aligned red, green, and blue channels are stacked together to form the final color image. The resulting image is converted to 8-bit format using (im * 255).astype(np.uint8)
to ensure proper color representation, and then saved to disk as a JPEG file with the suffix _colored
.
The displacements used for the alignment of each image are printed to the console for reference.
The program is designed to process multiple files in a batch. A list of image files is processed sequentially using the process_files()
function, which performs all the steps mentioned above for each file in the list.