Basic program structure
- Process command-line arguments: exit if not all the files indicated can be read in,
or if anything about the command-line arguments was unexpected.
- Determine the region in world-space that will be sampled by the output image,
based on the equations in the "What the rsmp program computes" section of the assignment.
- Create the output array for the 8-bit grayscale baseOut.png
- If not using the box kernel, create arrays for both the un-normalized gradient
vectors (so they have to be measured only once), and for the 8-bit RGB baseOut-grad.png
Steps below involving gradients are skipped with the box kernel.
- Create a function, perhaps called probe(),
which you can use to answer, for a given oriented image,
"What is the value and gradient at this location in world space?"
This will involve the inverse of the index-to-world transform,
and its inverse-transpose for transforming gradients. Inside probe()
you will be using the specified kernel to create a separable 2D kernel for 2D
convolution.
- The domain of the 1D kernel (box, tent, or bspln3)
is logically an axis of input image index space: 0 is at some input image pixel, 1 is at the next
pixel along that axis, and -1 is at the previous pixel. The box kernel implement
nearest-neighbor interpolation because the kernel is non-zero only for locations
that are closer to 0 than to any other integer.
- The main outer loops of your program are going to be traversing pixels in the output image,
not the input image. For each output image pixel, you have to find where the output pixel
center is in world space, and probe() there to get the value and gradient
for that output image pixel.
- What you will not be doing is: traversing the input image pixels, transforming
their locations to world space and then to output image index space, setting those output
pixel values, and then convolving to fill in the rest.
- Values in
baseOut.png can be set on the first pass of traversing the output image pixels;
gradients should be computed (in world-space) stored if needed.
- Find the maximal gradient magnitude, normalize measured gradients by this, then
apply the gradient colormap vmap.png.
- Save out baseOut.png and baseOut-grad.png.
Setting $SCIVIS
As mentioned in the project description, having a consistent way to refer to your
scivis-2013 checkout, with an absolute rather than a relative path, may
come in handy (Project 1 might have benefitted from this too). First, you cd
into your scivis-2013 checkout. Then, in bash-like shells:
export SCIVIS=`pwd`
or in csh-like shells:
setenv SCIVIS `pwd`
Example results with rsmp
These example runs of rsmp assume that $SCIVIS has been set as above,
in order to access the test images provided for you in $SCIVIS/data/orimg/.
rsmp $SCIVIS/data/orimg/ ssix0.png ssix0-orient.txt 100 box foo ssix0-box
ssix0-box.png:
|
|
rsmp $SCIVIS/data/orimg/ six4.png six4-orient.txt 100 box foo six4-box
six4-box.png:
|
|
In fact, using the box filter, all 16 of the the sixN (high-resolution) and ssixN
(low-resolution) images should appear identical in world-space. Using the tent
filter shows a difference between the sixN and ssixN images:
rsmp $SCIVIS/data/orimg/ ssix0.png ssix0-orient.txt 100 tent $SCIVIS/vec2cmap/hue-mag.png ssix0-tent
ssix0-tent.png:
| ssix0-tent-grad.png:
|
|
|
rsmp $SCIVIS/data/orimg/ six4.png six4-orient.txt 100 tent $SCIVIS/vec2cmap/hue-mag.png six4-tent
six4-tent.png:
| six4-tent-grad.png:
|
|
|
Still, using tent, all 8 of the ssixN images should look the same as each other,
and all 8 of the sixN images should look the same as each other.
The dot.png image, when viewed with rsmp provides a picture of the
convolution kernel, because there is only one non-zero pixel.
rsmp $SCIVIS/data/orimg/ dot.png dot-orient.txt 30 box foo dot-box
dot-box.png:
|
|
rsmp $SCIVIS/data/orimg/ dot.png dot-orient.txt 30 tent $SCIVIS/vec2cmap/bow-dir.png dot-tent
dot-tent.png:
| dot-tent-grad.png:
|
|
|
rsmp $SCIVIS/data/orimg/ dot.png dot-orient.txt 30 bspln3 $SCIVIS/vec2cmap/bow-dir.png dot-bspln3
dot-bspln3.png:
| dot-bspln3-grad.png:
|
|
|
The bumpX and bumpY images are two different
samplings of the same underlying function in world-space (look at the
underlying bumpX.png and bumpY.png images to see
this), so their gradient magnitude images should look about the same:
rsmp $SCIVIS/data/orimg/ bumpX.png bumpX-orient.txt 60 tent $SCIVIS/vec2cmap/hue-mag.png bumpX-tent
bumpX-tent.png:
| bumpX-tent-grad.png:
|
|
|
rsmp $SCIVIS/data/orimg/ bumpY.png bumpY-orient.txt 60 tent $SCIVIS/vec2cmap/hue-mag.png bumpY-tent
bumpY-tent.png:
| bumpY-tent-grad.png:
|
|
|
The phoen?.png images are different views of an image of a phoenix with a
little "CMSC 23710" annotation. In world-space, the phoenix is always at the same
orientation and position. One of the examples below uses the optional "[centX centY]"
arguments to rsmp, and the last example uses the bspln3 kernel that
the 33710 students have to implement.
rsmp $SCIVIS/data/orimg/ phoen0.png phoen0-orient.txt 40 tent $SCIVIS/vec2cmap/bow-dir.png phoen0-tent
phoen0-tent.png:
| phoen0-tent-grad.png:
|
|
|
rsmp $SCIVIS/data/orimg/ phoen1.png phoen1-orient.txt 40 tent $SCIVIS/vec2cmap/bow-dir.png phoen1-tent
phoen1-tent.png:
| phoen1-tent-grad.png:
|
|
|
This example uses the [centX centY] arguments:
rsmp $SCIVIS/data/orimg/ phoen1.png phoen1-orient.txt 40 tent $SCIVIS/vec2cmap/bow-dir.png phoen1-shift 0 0
phoen1-shift.png:
| phoen1-shift-grad.png:
|
|
|
rsmp $SCIVIS/data/orimg/ phoen2.png phoen2-orient.txt 40 tent $SCIVIS/vec2cmap/bow-dir.png phoen2-tent
phoen2-tent.png:
| phoen2-tent-grad.png:
|
|
|
rsmp $SCIVIS/data/orimg/ phoen2.png phoen2-orient.txt 40 bspln3 $SCIVIS/vec2cmap/bow-dir.png phoen2-bspln3
phoen2-bspln3.png:
| phoen2-bspln3-grad.png:
|
|
|