Keywords: front-page

## Lab: Image Overlaying II

[Exercises] [Workspace]

Purpose: The purpose of this lab exercise is to overlay a binary annotation image onto a grey-level image using three different methods: union (or maximum), bitwise XOR, and gating.

Activities:

1. Build a "zoomed" image for overlaying a grid of numbers into.

   1. Use two Piecewise Linear operators to generate images of size 9x9 with pixel values ranging from 0 to 1.

      1. Glyphs:Khoros 1:Generate Data:Piecewise Linear
      2. Open the Piecewise Linear operator and set the following parameters:

             	Period: 9
             	Rise Time: 4
             	Fall Time: 4
             	Pulse Width: 0

         For one image, generate a pattern in the width direction, and for the other image, generate the pattern in the height direction. Make sure that the `Sampling Freq` parameter is set to 1.

   2. Multiply these images together using the Multiply operator.

      - Glyphs:Arithmetic:Two Operand Arithmetic:Multiply

   3. Normalize the image from 0 to 255 using the Normalize operator. Convert the image to unsigned byte.

      - Glyphs:Data Manip:Data Conversion:Normalize

   4. Expand the image by a factor of 18 in the width dimension and 13 in the height dimension. These factors were chosen so that this image will exactly match with the annotated numbers in the file $DIP/data/numbers.pbm.

      - Glyphs:Data Manip:Size & Region Operators:Expand

   5. Display the image

      - Glyphs:Visualization:Non-Interactive Display:Display Image

2. Overlay the binary annotations onto the zoomed image that you created in Part 1.

   1. Select and display the $DIP/data/numbers.pbm image. Use operators User defined and Display Image. Verify if the pixel data type of the image is bit using the Data Object Info and File Viewer operators. If that is the case, it is necessary to convert the image to unsigned byte and normalize it between 0 and 255 using the Normalize operator.

      1. Glyphs:Input/Output:Data Files:User defined
      2. Glyphs:Visualization:Non-Interactive Display:Display Image
      3. Glyphs:Input/Output:Information:Data Object Info
      4. Glyphs:Input/Output:Information:File Viewer
      5. Glyphs:Data Manip:Data Conversion:Normalize

   2. Take the union of the image created in Step 1 and the numbers image, using the Maximum operator. Display the result.

      - Glyphs:Arithmetic:Two Operand Arithmetic:Maximum

   3. Apply the bitwise XOR operator to the same two images and display the result.

      - Glyphs:Arithmetic:Bitwise Operators:XOR

   4. Apply the Gate Data operator to create an image where the overlay numbers are all visible, and display the result. This requires an additional processing step.

      1. Add the constant value of 128 to the zoomed image and display the result. Note that there is overflow in this operation. In this case the overflow effect is desired.
      2. Glyphs:Arithmetic:Two Operand Arithmetic:Add
      3. Using the Gate Data operator, combine the zoomed image from Part 1 (as "Input 1"), the image you just created (as "Input 2"), and the numbers image as the "Gating Input".
      4. Glyphs:Arithmetc:Two Operand Arithmetic:Gate Data

   5. Compare the results from parts B, C, and D.

Exercises

1. Combine the gray-level zoomed image with colored numbers? You can use the technique explained in a lesson ahead called "Color Image Composing".

Khoros Workspace
Execute the visual program c3s4combine-zoom-number.wk