Color Selection and Cute Squirrels

This image of a squirrel was created during our research last summer while we were working on developing new functions for the Scheme library.

It demonstrates one possible use of the image-select-by-color! function which takes a color and selects all of the areas in the image whose pixels fall within the given threshold of the color.

Image-select-by-color! takes three parameters: an image where the selection will be made; a color value to select; and threshold, which indicates the extent selected colors can vary from the color parameter. The threshold value must be greater than or equal to 0 and less than or equal to 255. As threshold gets closer to 255, image-select-by-color! will select a wider range of color areas whose hues are similar to the color given (when it equals 255, it will select the entire image).

To create the image above, the student found a squirrel online and used image-select-by-color! with the rgb-value 60 120 60 (a light green color). Since the threshold given was 120, the function selected a relatively wide range of colors. Once the color areas were selected, the student filled the selection with the “Crinkled Paper” pattern that comes with the GIMP. She then inverted the selection and filled the remaining areas with black to achieve the final image.

The original image

The image-select-by-color! function has a wide variety of artistic uses. By selecting large color areas and filling them with a solid color, we can create images similar to the Obama campaign “Hope” poster. What other uses can you think of?

Here is the student’s code:

(define image1 (image-load “squirrel.jpg”))
(image-select-by-color! image1 (rgb-list->rgb (list 60 180 60)) 120)
(context-set-pattern! “Crinkled Paper”)
(image-fill-pattern! image1)
(image-select-inverse! image1)
(context-set-fgcolor! “black”)
(image-fill-selection! image1)
(image-select-nothing! image1

Advertisement

One thought on “Color Selection and Cute Squirrels

  1. Pingback: Shearing & Rotating « Media Scripting

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s