These are some of the resulting images.
There are basically four steps in the processing:
1. Cropping the image: I crop 1/10 of the image in every side
2. Resizing the image (similar to image pyramid): downscaling the image (usually I use a factor of 0.25) to reduce searching time If I am calculating over a small image which doesn't need downsizing, I would set the factor to be equal to 1.
3. Searching for the displacement: Performing exhaustive search over a window. I usually set the window to be [-1/10 of the image width, 1/10 of the image width]. In this window, I calculate the SSD of all pixels over two channels, and use the one with the least SSD as the displacement vector. If the displacement vector that I got is equal to the borders of the window, I would extend the window to [-1/(n-1) of the image width, 1/(n-1) of the image width] until the displacement vector is within the searching window.
4. Outputing the final result: roll the channels according to the displacement vector*(1/downscale factor) calculated from step 3, stack the three channels and output image.
For Emir, the problem is that the brightness of the three color channels aren't the same.
cathedral.jpg: G(20, 8) R(48, 12)
church.tif: G(24, 4) R(56, -4)
emir.tif: G(48, 24) R(104, 56)
harvesters.tif: G(60, 16) R(124, 12)
icon.tif: G(40, 16) R(88, 24)
lady.tif: G(52, 8) R(112, 12)
melons.tif: G(80, 8) R(180, 12)
monastery.jpg: G(-12, 8) R(12, 8)
onion_church.tif: G(52, 28) R(108, 36)
self_portrait.tif: G(80, 28) R(176, 36)
three_generations.tif: G(52, 12) R(112, 12)
tobolsk.jpg: G(12, 12) R(24, 12)
train.tif: G(44, 4) R(88, 32)
workshop.tif: G(52, 0) R(104, -12)