Project Description

The Project Goal was to take separated RGB channels that are slightly misaligned, compute the correct alignment and then recombine them. The main issue I faced was that the intensities of the different channels can differ significantly, making matching difficult. I tried many different strategies to overcome this: Normalizing the images by subtracting the mean and dividing by standard deviation, using Matlab's 'histeq' to transform one image to have similar intensity as the other, and others. Some worked well on most images but few worked well on all of them. The method I ultimately chose was to filter each image first with edge detection filters, thus creating an image where the only bright regions are near edges. This helped to alleviate the problem of image intensities not matching up well between the color channels, as most edges appeared in each color channel. I tried both SSD and NCC as metrics for computing the matching score, I found the results to be nearly identical and so I chose SSD for speed. For 'Bells and Whistles' I implemented a border-stripping function to remove the odd color-streaked borders that resulted from the misalignment of the color channels.

Example Results: offsets are listed as (row, col)

Small Image (jpg) Results

00106v.jpg Offset: R(9,-1), G(4,-1) 00757v.jpg Offset: R(5,5), G(2,3)
00888v.jpg Offset: R(12,1), G(6,1) 00889v.jpg Offset: R(5,3), G(2,2)
00907v.jpg Offset: R(6,0), G(2,0) 00911v.jpg Offset: R(13,-1), G(1,-1)
01031v.jpg Offset: R(4,2), G(1,1) 01657v.jpg Offset: R(12,1), G(6,1)
01880v.jpg Offset: R(14,4), G(6,2)

Large Image (tif) Results (click on images for larger versions)

00029u.tif Offset: R(96,37), G(40,21) 00087u.tif Offset: R(106,54), G(48,36)
00128u.tif Offset: R(52,37), G(36,25) 00458u.tif Offset: R(82,28), G(40,-1)
00737u.tif Offset: R(50,14), G(16,7) 00822u.tif Offset: R(120,31), G(56,22)
00892u.tif Offset: R(62,86), G(16,1) 01043u.tif Offset: R(12,14), G(-9,12)
01047u.tif Offset: R(72,33), G(24,19)

The only problematic image here is 00892u.tif. You can see that the alignment is far off in one of the color channels. The alignment is made difficult by the different color channels having different intensity. The images in this set with dark blue water proved particularly difficult as a result, since the blue color channel will differ significantly from red and green. I was able to get each image in the set to align quite well using different techniques, but no one technique aligned all of them perfectly. The best I was able to come up with left this one poorly aligned.

A Few Examples of My Own Choosing

00542v.jpg Offset: R(11,1), G(5,1) 00645v.jpg Offset: R(14,-1), G(7,0)
01007v.jpg Offset: R(13,1), G(6,1)

Bells and Whistles

I implemented a function to strip the ugly color-streaked borders that often resulted from the misalignment of the color channels. I did this by checking if the R,G,or B values differed greatly from one another near the edges of the image, moving inward until they were reasonably close in value. I also checked for very dark or very white regions near the edges, which also indicated border regions. The border detection and removal works well on the majority of images, grey border however may fool it, as the color channels agree on the value even though it isnt actually part of the image content. Below are some before and after image showing the border removal: