[Exercises]
[Workspace]
Purpose:
The purpose of this lab is to experiment with color and
colormaps. In this exercise, you will convert a black and white image
into a colored image using colormap utilities.
Activities:
-
Experiment with labelling and building an RGB color table.
-
Read and display the image $DIP/data/unicamp-logo.kdf. Use
the User defined and Display Image operators.
-
Glyphs:Input/Output:Data Files:User defined
-
Glyphs:Visualization:Non-Interactive Display:Display Image
-
Swap the background and foreground pixel values by subtracting
all pixel values from 255. Use the operator Subtract From. Why is
this necessary? This is explained in the "Labeling" lesson in the
Image Manipulation Section (lab 10).
-
Glyphs:Arithmetic:Two Operand Arithmetic:Subtract From
-
Label the image that you just created using the Labeling (mmach)
operator of the MMACH toolbox, with "connectivity" set to 4, and display
it with the Display Image operator.
-
Glyphs:MMACH:Connected Filters:Labeling (mmach)
-
Glyphs:Visualization:Non-Interactive Display:Display Image
-
Use the Statistics operator to determine the total number of
labeled regions.
-
Glyphs:Data Manip:Analysis & Information:Statistics
-
Glyphs:Input/Output:Information:File Viewer
-
Build an ASCII color table with 3 columns (RGB) and the same
number of rows as the number of regions in the labeled image. Choose
the color you want for each region. If you wish, you can create this
file using an ASCII editor. For convenience, there is an RGB color
table for you to use, the file is $DIP/data/unicamp-lut.ascii. You
can view this file using the File Viewer.
-
Glyphs:Input/Output:Data Files:User defined
-
Glyphs:Input/Output:Information:File Viewer
-
Convert the "ASCII" color table to a "kdf colormap" using the
operator ASCII to Map.
-
Glyphs:Input/Output:Import Data:ASCII to Map
-
Open the ASCII to Map and set the proper parameters (Width = 3,
Height = 24). Set the data type to "unsigned byte".
-
Display the color table using the operator Display Palette.
-
Glyphs:Visualization:Map Display & Manip:Display Palette
-
Explore three ways of representing/displaying the color image.
-
Using the Display Image operator, input the labeled image and
the color map separately.
-
Glyphs:Visualization:Non-Interactive Display:Display Image
-
Connect the labeled image (output of Labeling (mmach)
Operator) to the first input of Display Image, and connect the colormap
(output of ASCII to Map) to the second input (Colormap Image). Verify that
although the image is colored, the pixel value under the cursor shows
the VALUE data (you may need to resize the window to see all of the
position information).
-
Combine the colormap (map segment) and the labeled logo image
into a single data object using the operator Insert Segments. Display
the resultant image.
-
Glyphs:Data Manip:Segment Operators:Insert Segments
-
Glyphs:Visualization:Non-Interactive Display:Display Image
-
Connect the colormap to "Input 1" of the Insert Segments
operator, and connect the output of the Labeling (mmach) operator to
"Input 2".
-
Open the Insert Segments pane and set it up so that the "Map"
segment is inserted into the labeled image.
-
Display the results.
-
Using the image you just created, map the value data through
the color table (map) by using the operator Map Data. Set the data
object color attribute to colorspace RGB before dis- playing it. Use
the operator Set Attribute.
-
Glyphs:Data Manip:Map Operators:Map Data
-
Glyphs:Data Manip:Object Attributes:Set Attribute
-
Glyphs:Visualization:Non-Interactive Display:Display Image
-
The only parameter you need to set in the Set Attribute
operator is the "Data Object Color Attributes: Colorspace
Parameter". Select the "Colorspace" option and set it to "RGB".
-
Display the resulting image. Note that when you pan around in
the image with your cursor, the values of all three elements are now
printed.
-
Print out the header contents of the following data objects:
Labeled image
Colortable data
Labeled image together with the colortable
Mapped image
and interpret the contents with respect to the dimensions of the
segments "value" and "map". Use the Data Object Info and File Viewer
operators.
-
Glyphs:Input/Output:Information:Data Object Info
-
Glyphs:Input/Output:Information:File Viewer
Exercises
-
Compare the sizes of the mapped image (output of Map Data) and the
labeled image file with the color table (output of Insert Segments).
-
Is it useful to have a color table with only a single
column. What are the advantages of using it?
Khoros Workspace
Execute the visual program c4s1logo-color.wk
Main DIP Menu
DIP Feedback Form
Copyright © 1997-1995 KRI, ISTEC, Ramiro Jordán, Roberto Lotufo. All Rights Reserved