Project 1 - Colorizing LoC Collections
Faustinus Kevin Gozali (fkg@andrew.cmu.edu)
Usage
In Matlab: output = colorize(imageFileName);
The function takes in the image file name as the input, and outputs the colorized (RGB) image based on the input.
Basic Approach
The colorization requires alignment on the color channels. In this project, the R and B channels are aligned with respect to G channel. To speed up the alignment process, a N-level multi-scale pyramid alignment is used, where N varies depending on the size of the input image. At each level of alignment, we search over a window of displacement to find the best fit, by finding the maximum correlation in the window. The three channels are then combined into a 3-channel RGB image as the output.
- N = floor(log2(max(size(R or G or B))/50)
- Correlation value of A and B is: dot(A(:)/sum(A(:)), B(:)/sum(B(:)))
- The search window for each level is [-5:5] x [-5:5]
Improvement: Removing Border Artifacts
Apparently, doing only the pyramid alignment does not produce an ideal result. The most notable error is most probably caused by the white and black borders on the input images. These borders are clearly not part of our images of interest; they should be discarded somehow. The following steps define the mechanism:
- Start from the input image and try to remove the white borders first. We remove the left, right, top, bottom borders one at the time. For each border, we start with the outer most possible border and compute the average color covered in that border line (for left and right borders, we compute the average color in the 1-pixel-width vertical borderline; horizontal borderline for top and bottom borders). We check the average sum if it is brighter than T-WHITE, which denotes bright white colors. If so, we check the next borderline (from the outermost borderline towards the center), until we find the one "that is not white". However do to the possible noise, we set a tolerance value: W-MAXERROR. By this, we allow at most W-MAXERROR consecutive borderlines that is NOT greater than T-WHITE. If this limit is exceeded, then we stop our search.
- Now that the white border is somehow removed, we need to kill the black border. Computing the average color does not work that well for this border. Thus, we start by dividing the whiteborder-free image into 3 equally sized R,G,B channels. Similar as before, we try to remove left, right, top, bottom borders one at a time. For each border, we dot product the borderlines for each of the R, G, and B channels. The idea is: if one of the channel shows a highly dark border, the dot product of the 3 lines would be close to 0.0. We check this value against T-BLACK like before. Again, we allow tolerance B-MAXERROR (this one varies depending on the size of the image), and finally stop when this limit is exceeded.
- Now, the black and white borders are mostly gone, although some parts are still there. We pass this result to the pyramid alignment function
- To get rid of minor border artifact as the result of circshift, we find the good region for all RGB channels. This is done by finding the overlapping horizontal and vertical ranges that are not affected by circshift. Only pixels in this good region will be used.
- Finally, we get the final colorized result.
- T-WHITE = 0.91
- T-BLACK = 0.018
- W-MAXERROR = 9
- B-MAXERROR = floor(7/350 * width of the R, G, or B channel)
- Note that these parameters are a little aggresive, resulting in slightly smaller output images due to heavy cropping. Reducing T-BLACK and MAXERROR params will produce slightly larger output images, but some border artifacts are not removed properly in some images.
Example
Original Input Image
|
White Border Cropped
|
Results
00125v.jpg
|
00149.jpg
|
00153v.jpg
|
00163v.jpg
|
00270v.jpg
|
00374v.jpg
|
00398v.jpg
|
00548v.jpg
|
00737v.jpg
|
00882v.jpg
|
01167v.jpg
|
01468v.jpg
|
01880v.jpg
|
01898v.jpg
|
The following large images are in JPEG format. Click on them to view the full sized version.
00458u.tif
|
00500u.tif
|
00911u.tif
|
01043u.tif
|
01047u.tif
|
01657u.tif
|
September 13, 2006