Computer Vision (CSE 490CV/EE 400B), Winter 2002

Project 0:  Image filtering

Assigned:  Friday, Jan 11, 2002
Due:  Thursday, Jan 17, 2002 (by 11:59pm)


Goal

  1. To implement and get experience with image filtering--a basic image processing operation.
  2. To get comfortable with image data structures and user-interface programming with FLKT.

Description

You will implement a simple window-based image filtering tool, called imgflt.  This tool allows you to load an image and apply any 5x5 cross-correlation filter to it.  The filter may be applied to the entire image, or "brushed" on to any selected region.

You will be given a working skeleton program, which provides the user interface that you'll need for this program.  Specifically, it allows you to load in an image and specify any 5x5 filter by typing in the filter coefficients, a scale factor which multiplies each filter coefficient, and an offset which is added to the pixel before displaying.  The interface supports loading and saving of both images and filters.  You can also change the brush size.  For a complete description of which mouse button does what, run the program and select the "Help" menu item.

We have provided a sample solution executable and test images.  Try this out to see how your program should run.  Pay special attention to the behavior of the brush.  It should apply the filter to each pixel only once, even if the brush is moved over that pixel multiple times.  This may be accomplished by copying the image to a temporary image which is the one currently displayed.  Filtering operations affect the temporary image but leave the original image intact.  When you click "Accept" in the filter window, the changes are committed to the original image.

You will write the code to do cross-correlation filtering.  First, however, you should check out the online documentation for FLTK 1.0, a cross-platform user interface and graphics API that we'll be using in this class.

Skeleton Code

You can download the skeleton files. The code is compiled in Visual C++ 6.0, and organized by the workspace file imgflt.dsw. All the source files (.h/.cpp) are in the subdirectory src.  There are 21 files total, but many are just user interface files that are automatically generated by fluid, the FLTK user interface building tool.  Here is a description of what's in there:

To Do

  1. Get familiar with FLTK.
  2. Read the skeleton files, especially ImgFltMain.cpp, correlation.h/cpp, and imgView.h/cpp.
  3. In correlation.cpp, implement image_filter(...) function, which carries out 2D image filtering.
  4. In correlation.cpp, implement pixel_filter(...) function, which carries out 2D image filtering only for a specified pixel (used for the brush). You could call pixel_filter from image_filter while you are debugging, but it will run slowly since you're making a function call for every pixel.  In your final version, you will want to inline the pixel filtering code in image_filter.
  5. In ImgView.cpp, finish the handle(...) function, such that when you drag the mouse with left button down, the filter is applied wherever the mouse moves. Make sure that if the mouse moves to the same position twice, the filter is applied only once.  After the result is accepted any region may be filtered again.
  6. In ImgFltMain.cpp, generate help info about how to use your application in my_img_filter(...) if you added any new features.

Data Structure


We're not expecting anything fancy beyond the basic requirements on this project, although you're welcome to add to it if you'd like.  We probably won't be giving out extra credit on this project since it's meant to help people get up to speed quickly with the tools and data structures.

Correction

  • For those of you who have already started working on the skeleton codes and are confused about the square and round brush features, I have updated a new ImgView.cpp file for you to use. This file is almost the same as its old version, except that I put more comments and hints for TO DO 3. You can download it and insert it your imgflt workspace. (The current link above to skeleton codes has also been updated to contain this new imgView.cpp)
  • For those of you who read the code deeply, do not worry about the attributes of TARGA image format if they bug you. The current code is doing fine.

  • Last modified on January 09, 2002