Convolution Principles
Building the Cantata Workspace
At the time this lesson was prepared, both the linear and circular
convolution operators in Khoros had small problems. So to fully
reproduce linear and circular convolution with the Khoros Linear operator,
the original images have to be zero extended for linear convolution or
periodically extended for the circular convolution. Also, in both cases
the correct portion of the image has to be extracted.
In this experiment the image $DIP/data/draw-small.viff is used.
It is a 32 x 32 image with floating point pixels with values 0.0 and 1.0.
1. Create the zero extended image
Select the image $DIP/data/draw-small.viff and zero extended it
to size 64 x 64, so that the input image appears in the center. Use
operator
Pad.
2. Create the periodic image
Select the image $DIP/data/draw-small.viff and create a 4 x 4
mosaic using the operator
Inset
twice. First to put two images side by side and the second to put this
two-images top by bottom.
3. Create the Zoom Display Procedure
As the extended or periodic image is small (64x64), create a procedure
to display it
zoomed by 4 using the operators:
Expand
and
Display Image. Call this procedure Zoom Display.
You can see
how to create a procedure in cantata.
4. Building the kernels
- shifted h(2,2) = 1
Use the operator
Impulse.
- 3x3 average
Use the operator
Constant.
- Sobel X
Use the file $DIP/data/sobel_x.viff and operator
User defined. You can view this ASCII file using the
File Viewer operator.
5. Performing the convolution
Use operator
Linear Operator to perform the convolution.
Extracting the correct portion of the resultant image
Use the operator
Extract
to select the correct portion of the image.
For linear convolution, you need to extract an image 2 pixels wider
and 2 pixels higher that the original since the kernel dimensions are 3x3.
For periodic convolution, you need to extract the bottom left image,
since the kernel origin is at (0,0)
Exercises
- Explain how the position of the extracted image is dependent on the
kernel origin.
- Create an encapsulate workspace operator to fully implement the
linear and circular convolution for any kind of kernel.
DIP Feedback Form