Program 4: Color Transfer Between Images
Source of Algorithm |
Summary | Instructions
| PPM Format |
PGM Format |
Submission Instructions
Read in a two (2) PPM format image files from the command line. The first file is the target
image. The second is the reference image for the colors to be applied to the
first file. Scale the colors in the first image to match the mean and
standard deviation in the second file and output it.
- Your program should take two file names as command-line arguments.
- The first file is the target file.
- The second is the reference image to scale the other image by.
- Store the RGB values for the target image and the reference image.
- For both images:
- Convert the RGB values to LMS values. (Each pixel will now have an L, M, and S
value instead of an R, G, and B value.)
- Find the log of each L, M, and S value.
- Convert the log of L, M, and S to L, A, and B.
- Find the mean for L, A, and B: find the average L value, the average A value, and the
average B value.
- Find the standard deviation for L, A, and B: find the standard deviation for the L values, the standard deviation for the A values,
the standard deviation for the B values.
- Scale the target image to have the same mean and standard deviation for its LAB values:
- Subtract the average L value in the target image from each pixel's L value.
- Multiply each L value by the standard deviation of L for the reference image
over the standard deviation of L for the target image.
- Add the average L value from the reference image to each pixel's L value.
- Do the same procedure for A and B.
- For each pixel in the target image, convert LAB to LMS.
- Compute 10 to the power of L, M, and S for each pixel.
- Convert the log of L, M, and S to R, G, and B.
- Write the image to standard out in PPM format.
Examples
- Your C program file should be named colortransfer.c. You may turn in a separate
file for the conversions (e.g. convert.c).
- Hand in program
colortransfer.c convert.c
no later than 11:59 p.m. Friday November 28th-
Email
-
source code attachment(s)
colortransfer.c convert.c
-
subject line:
CSC 112 Program 4r
- Keep the email submission confirmation for reference later.
Summary | Instructions
| PPM Format |
PGM Format |
Submission Instructions
|