Natalie McHale CPSC 4040 Fall 2018ioannis/cpsc6040/2017/projects/nm… · McHale 1 . Natalie McHale...
Transcript of Natalie McHale CPSC 4040 Fall 2018ioannis/cpsc6040/2017/projects/nm… · McHale 1 . Natalie McHale...
McHale 1
Natalie McHale
CPSC 4040
Fall 2018
Applying a Limited Color Palette
The Focus
• For the final project I focused on suggestion number two. Suggestion number two was described as a
“Color mapping to a limited image palette. Painters regularly work from a limited palette (i.e. a small set of
premixed colors on their palette) from which they do a painting. Make a program that will accept a limited
palette, and then map colors in an image to appropriate colors from this palette, producing an output image
in the limited palette.”
Input
• For the program input the user has to supply a .txt file into the program with the number of colors they are
choosing for the new color palette and the rgb colors associated with each color.
• The user will also need to provide an input image (specifically a .png) that we apply the limited color
palette to.
• The user can optionally give an output file name at the command line, but if one is not provided we will
provide a new name for them if they wish to write the image to a file.
The Work
• The palette will be applied to an input image using two different methods. The first method is one in which
we look at every single pixel in the input image independently, determine which color from the given
palette is most similar, (calculated based on the distance from each color) and then we change the pixel at
every location. The first method is invoked by the user hitting the ‘p’ or ‘P’ key. The second method is to
consider the error from changing the color. In this method we implement Floyd-Steinburg’s algorithm to
distribute the error to neighboring pixels. This second method is invoked by the user hitting the ‘d’ or ‘D’
key.
McHale 2
Output
• The newly altered image will be displayed on the screen.
• The user will have the option to write this image to a file with keyboard commands.
• The user can decide to reload the original image and apply a different method with the same color palette
without needing to exit and reload the program.
• Once the user hits either the ‘q’, “Q’, or ‘esc’ key the program will exit.
Examples of Valid .txt Files
McHale 3
Examples of Method 1 versus Method 2 with Example .txt Files on Multiple Input Images
McHale 4
McHale 5
McHale 6
McHale 7
McHale 8
McHale 9
McHale 10
McHale 11
McHale 12
Summary of Output Images Overall Characteristics
• (blackandwhite.txt) Instead of seeing big “chunks” of black or white, dithering allows us to disperse the
error and spread the colors in a more effective way to obtain more details in our image.
• (RGBTester.txt) The difference between the two methods are show cased when we allow red, green, and
blue to be the only colors. In the first method we see large “chunks” of color. These “chunks” do not all us
to see details or layers in the images. In the case where we use dithering, we observe layers of the image
and can distinguish between different sections of the image.
McHale 13
• (pinkpurple.txt) In the pink and purple palette we are able to see the details that we are able to add to the
image with dithering. Without spreading the error to the neighboring pixels we notice big “chunks” of the
same color, which do not help us to see what the image is supposed to be, when we use dithering in this
example, the image is completely transformed and we are able to see virtually all of the details from the
original image.
• (redgreen.txt) In the first example, we are clearly able to see the effect of dithering. We see that instead of
having strict defined color grids, we are able to spread out the color and achieve a smoother transition from
color to color, which helps us to achieve a better replicated image.
McHale 14
• (neon.txt) In these examples we can clearly see that by allowing the error of the color being passed to
neighbors, we are able to obtain a better overall idea of the image. In the first example we cannot see
anything without dithering, but with dithering we are able to start to see the main “ideas” of the image.
• (pastel.txt) The pastel palette is interesting since we are not able to see as much detail on the dithered
image. This is opposite of what we expect to observe, and more research would be needed to explain this
observation.