main-resizehints

Hints for Resizing

Here are some notes from my experience implemented a sample version of the resizing part of Project 1.

First: you can find the executable in:

    P:\course\cs559-gleicher\public\bin\2009

Or download it: (link).

It has a few more bells and whistles than yours might (like the ability to generate the set of different kernel outputs as shown in last year’s notes).

You don’t need to implement all the kernels I did. Looking at that page, will also give you some hints as to how my code is structured.

How I structured my code

If you’re wondering, my program is 380 lines long. Over 100 of these are the 8 filters I implemented. My implementation is designed to make it easy to write and test (not necessarily for efficiency).

For a big hint, here are the C++ signatures of 5 key functions in my code:

    void getRow(TargaImage*, size_t row, vector& red, vector& green, vector& blue);
    void putRow(TargaImage*, size_t row, vector& red, vector& green, vector& blue);
    void getCol(TargaImage*, size_t row, vector& red, vector& green, vector& blue);
    void putCol(TargaImage*, size_t row, vector& red, vector& green, vector& blue);
    void resample(Filter* filter, std::vector& in, std::vector& out);

As you can see, I pull out a row or column at a time (since things are seperable).

The “resample” function is clearly the meat of the project, but its only 50 lines (including comments) and about 8 of those are to deal with the special case of the spike filter kernel.

I have a “basic version” of the assignment which only does nearest neighbor resampling, but is otherwise complete. It also implements the same functions above, except that its version of resample is only 5 lines long (and there are now filter kernel definitions). The whole thing is 157 lines of code, sparsely commented.

You can look at results of this program for downsampling at Main.Downsample, which will link you to upsampling examples, which will actually give you the kernels.

Where do I get the kernels from?

Look in the book! Or, look at other hints since I actually gave out my code. But look in the book first to see what they really should be.

Page last modified on September 25, 2009, at 11:38 AM