[Exercises]
[Workspace]
Purpose:
The purpose of this lab is to learn image composing and
editing. The goal is to frame the gull image with a ruler. The use of
variables in the cantata workspace is introduced in this lab.
Activities:
-
Display the ruler as an aid in developing the workspace using
the User defined and Display Image operators. The ruler image file
is $DIP/data/ruler.kdf. The image dimensions are 512 x 14. The major
tics and numbers are 7 pixels high.
The operators required to follow the steps described below are:
-
Glyphs:Data Manip:Size & Region Operators:Extract
Create a Region Of Interest (ROI)
-
Glyphs:Data Manip:Size & Region Operators:Inset
Combine two images by pasting the second image such that its
top left corner pixel goes to the inset coordinates of the first
image.
-
Glyphs:Data Manip:Reorganize Data:Flip
Reflects the data along the specified coordinate.
-
Glyphs:Data Manip:Reorganize Data:Switch Axes
Swaps the coordinates of the image.
-
Create rulers for each edge of the "seagull" image. To add
flexibility to your visual program, use the "Variables"
functionality. Use WIDTH as a variable to control the width of the
image to be extracted from the original.
-
Get size information about the sea gull image using the Data Object Info
and File Viewer operators.
-
Glyphs:Input/Output:Data Files:User defined
-
Glyphs:Input/Output:Information:Data Object Info
-
Glyphs:Input/Output:Information:File Viewer
-
Create the bottom ruler.
-
This is the original ruler, but needs to be extracted to the same
width as the image.
-
Open the Workspace:Variables... form
-
Type the following expression into the "Define Variables /
Evaluate Expressions" window "WIDTH = 256", and then select the
"Cancel" button.
-
Open an Extract operator pane, but instead of typing in the value
of the width (256), type in the variable name "WIDTH". Unselect all
other dimensions.
-
Connect the ruler input to Extract, and connect Extract to
a Display Image operator.
-
Run Extract and display the results to verify that they are
correct.
-
To keep track of which ruler is which, change the label on
the Extract operator from Extract to "Extract (Bottom)". Do this by
clicking on the glyph title and filling out the pop-up form.
-
Top ruler:
-
Extract the numbers of the ruler (first 7 pixels of the bottom
ruler) Use the variable HEIGHT (7) in the same way as WIDTH was used
in part A. The HEIGHT variable can be used for both the "Region Size"
and the "Region Origin". It is a good idea to verify your results in
each of these using a Display Image operator.
-
Extract the ticks of the ruler (top 7 pixels of the bottom ruler).
-
Flip the ticks along the Height dimension so that they face down.
-
Inset the ticks below the numbers. Use the HEIGHT variable with
the Inset operator.
-
Relabel the Inset operator to be "Inset (Top)"
-
Left Ruler:
-
Swap the axes (width by the height) of the bottom ruler using
the Switch Axes operator.
-
Flip the results about the width dimension using the Flip
operator.
-
Relabel the Flip operator to be "Flip (Left)"
-
Right ruler:
-
Repeat the same procedure as for the Left ruler, but using the
top ruler instead of the bottom ruler.
-
Relabel the Flip operator to be "Flip (Right)".
-
Frame the sea gull image with the rulers. Inset the four rulers
at the proper positions of the original image, using the WIDTH and
HEIGHT variables.
-
Attach the Upper Ruler.
-
Select Glyphs:Data Manip:Size & Region Operators:Inset from the cantata menus, and duplicate it so that
there are 4 Inset Operators.
-
Connect the "Upper Ruler" image to "Input 1" of the first Inset
operator.
-
Connect the sea gull image to "Input 2". Set the "Height
Coordinate" to 2*HEIGHT.
-
Connect the output of this "Inset" to "Input 1" of the next Inset.
-
Attach the Bottom Ruler.
-
Connect the gull image to "Input 1" of the first Inset operator.
-
Connect the bottom ruler to "Input 2". Set the "Height
Coordinate" to "WIDTH + (2*HEIGHT)".
-
Connect the output of this "Inset" to "Input 1" of the next Inset
-
Attach the Right Ruler.
-
Connect the Right ruler to "Input 2", and set the "Width
Coordinate" to WIDTH and the "Height Coordinate" to 2*HEIGHT.
-
Connect the output of this Inset to "Input 1" of the next Inset
-
Attach the Left Ruler.
-
Connect the Left ruler to "Input 2", and set the "Width Coordinate"
to "-2*HEIGHT", and the "Height Coordinate" to "2*HEIGHT".
-
Display the result.
-
This workspace should work for any square image. Test it by
substituting the "Floating Ball" image for the "Spanish Sea Gull"
image. Determine the size of the new image and reset the WIDTH
variable before executing the workspace.
Exercises
-
Create an encapsulated workspace operator, so that you can use this
as a cantata operator.
Khoros Workspace
Execute the visual program c2s5flip-ruler.wk
Main DIP Menu
DIP Feedback Form
Copyright © 1997-1995 KRI, ISTEC, Ramiro Jordán, Roberto Lotufo. All Rights Reserved