Proj 1 Overview

Stephanie Kim

The goal of this project was to understand how to take red, blue, and green versions of an image and align them such that they create an accurate RGB picture. The premise is we start with an image, separate the red, blue, and green values and then run functions/processes to calculate correct displacements and then align them together (stack) to create the final RGB picture.

Started the process with the naive exhaustive search. Works pretty well with the small files (jpg). The function exhaustively searches the best displacement between the 2 given images using ssd (minimizing ssd). I then run this image on all of the jpg files (smaller files). I referenced a lot of the skeleton code to separate the b, g, and r channels. The displacement is given as [row, col] (aka [x, y]) by print statements preceeding each image.### Start the Process with the Naive exhaustive search. Works Pretty well with the small files (jpeg).

In [3]:
 
red displacement:  [7, -1]
green displacement:  [1, -1]
/Users/stephkim/anaconda/lib/python3.6/site-packages/skimage/util/dtype.py:110: UserWarning: Possible precision loss when converting from float64 to uint8
  "%s to %s" % (dtypeobj_in, dtypeobj))
/Users/stephkim/anaconda/lib/python3.6/site-packages/skimage/io/_plugins/matplotlib_plugin.py:51: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  out_of_range_float = (np.issubdtype(image.dtype, np.float) and
/Users/stephkim/anaconda/lib/python3.6/site-packages/matplotlib/axes/_base.py:1428: MatplotlibDeprecationWarning: The 'box-forced' keyword argument is deprecated since 2.2.
  " since 2.2.", cbook.mplDeprecation)
red displacement:  [9, 1]
green displacement:  [-6, 0]
red displacement:  [6, 3]
green displacement:  [3, 2]

Started using the image pyramid. For the monastery.jpg, this function works better. The function consists of recursively finding the best displacement of a coarser image and applying it to the next level (less coarse image) by using ssd (minimizing ssd). I had to play with the parameters for the base case and the range of the displacement, but these didn't vary much (took note of the class spec recommendations). The parameter that varied most were how much of the image to search when it's too big to do an exhaustive search. I initially had trouble implementing the recursion because I was so used to thinking of recursion as top down instead of bottom up, but once I finally made sense of that it turned out well. The displacement is given as [row, col] (aka [x, y]) by print statements preceeding each image.

In [5]:
 
red displacement:  [8, 2]
green displacement:  [4, 2]
/Users/stephkim/anaconda/lib/python3.6/site-packages/skimage/util/dtype.py:110: UserWarning: Possible precision loss when converting from float64 to uint8
  "%s to %s" % (dtypeobj_in, dtypeobj))
/Users/stephkim/anaconda/lib/python3.6/site-packages/skimage/io/_plugins/matplotlib_plugin.py:51: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  out_of_range_float = (np.issubdtype(image.dtype, np.float) and
/Users/stephkim/anaconda/lib/python3.6/site-packages/matplotlib/axes/_base.py:1428: MatplotlibDeprecationWarning: The 'box-forced' keyword argument is deprecated since 2.2.
  " since 2.2.", cbook.mplDeprecation)
red displacement:  [2, 2]
green displacement:  [-4, 2]
red displacement:  [6, 4]
green displacement:  [2, 2]
red displacement:  [128, 0]
green displacement:  [64, 0]
red displacement:  [96, 16]
green displacement:  [48, 16]
red displacement:  [-28, -12]
green displacement:  [16, 8]
red displacement:  [176, 16]
green displacement:  [96, 16]
red displacement:  [112, 32]
green displacement:  [48, 32]
red displacement:  [176, 32]
green displacement:  [80, 32]
red displacement:  [112, 16]
green displacement:  [48, 16]
red displacement:  [96, 32]
green displacement:  [48, 0]
red displacement:  [288, 48]
green displacement:  [160, 112]
red displacement:  [96, 0]
green displacement:  [64, 0]
red displacement:  [128, 16]
green displacement:  [64, 16]
CPU times: user 9min 1s, sys: 2min 20s, total: 11min 21s
Wall time: 6min 28s

I don't think this counts as a bonus, but I used an edge filter to improve the images. I applied the edge filter to the images before I split the images into r, g, b channels, and I then used the same process/function as with the Image Pyramid section. The displacement is given as [row, col] (aka [x, y]) by print statements preceeding each image.

In [6]:
 
red displacement:  [112, 16]
green displacement:  [48, 16]
/Users/stephkim/anaconda/lib/python3.6/site-packages/skimage/io/_plugins/matplotlib_plugin.py:51: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  out_of_range_float = (np.issubdtype(image.dtype, np.float) and
/Users/stephkim/anaconda/lib/python3.6/site-packages/matplotlib/axes/_base.py:1428: MatplotlibDeprecationWarning: The 'box-forced' keyword argument is deprecated since 2.2.
  " since 2.2.", cbook.mplDeprecation)
red displacement:  [96, 16]
green displacement:  [48, 16]
red displacement:  [32, 8]
green displacement:  [16, 0]
red displacement:  [176, 16]
green displacement:  [80, 0]
red displacement:  [112, 32]
green displacement:  [48, 32]
red displacement:  [176, 32]
green displacement:  [80, 32]
red displacement:  [112, 16]
green displacement:  [48, 16]
red displacement:  [80, 32]
green displacement:  [32, 0]
red displacement:  [144, 16]
green displacement:  [64, 16]
red displacement:  [112, -16]
green displacement:  [48, 0]
red displacement:  [128, 16]
green displacement:  [64, 16]
CPU times: user 9min 18s, sys: 2min 31s, total: 11min 50s
Wall time: 6min 59s