[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Chapter summary:
Image Processing is fairly (but not very) important in Computer Vision.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
vipl provides several image processing algorithms including
mathematical morphology, smoothing, edge filtering. All of these
algorithms are provided as filter classes. So there is a
vipl_gaussian_convolution
class, etc.
The pattern for using each filter is as follows.
vipl_filtering_operation<TEMPLATE TYPES> op(parameters); op.put_in_data_ptr(src_image_ptr); op.put_out_data_ptr(dst_image_ptr); op.filter(); |
The TEMPLATE TYPES and parameters depend on the actual operation. Common template parameters include the types of the source image, the destination image, the source pixels, the destination pixels, and the pixel iterator. So a concrete use might be:
typedef vil_memory_image im_type; im_type src(width,height,1,VIL_PIXEL_FORMAT_BYTE), dest; ... vipl_gaussian_convolution<im_type,im_type,vxl_byte,vxl_byte,vipl_trivial_pixeliter> op(2.0); op.put_in_data_ptr(&src); op.put_out_data_ptr(&dest); op.filter(); |
All of the concrete classes depend on an abstract class tree including vipl_filter<>, which automatically provides the ability to work on images that are too large to be fit into memory in one go.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The following concrete operations have been implemented so far
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
It is probably easiest to follow an example. However, the basic
minimum required is to override section_applyop()
. It
should scan through the whole section, and set the output
accordingly. For example
template <class ImgIn,class ImgOut,class DataIn,class DataOut,class PixelItr> bool vipl_gradient_dir <ImgIn,ImgOut,DataIn,DataOut,PixelItr> :: section_applyop() { const ImgIn &in = in_data(0); ImgOut &out = *out_data_ptr(); DataIn dummy = DataIn(); register double dx, dy; int startx = start(X_Axis()); int starty = start(Y_Axis()); int stopx = stop(X_Axis()); int stopy = stop(Y_Axis()); for (int j = starty; j < stopy; ++j) for (int i = startx; i < stopx; ++i) { dx = fgetpixel(in, i, j, dummy) - getpixel(in, i-1, j, dummy); dy = fgetpixel(in, i, j, dummy) - getpixel(in, i, j-1, dummy); dx = (vcl_atan2( dy, dx ) + shift()) * scale(); fsetpixel(out, i, j, (DataOut)dx); } return true; } |
Use of the start()
, stop()
, X_Axis()
,
getpixel()
, setpixel()
, etc. inline functions means
that your new filter will work with any image type that vipl
supports.
If you need to pre-calculate something, such as an FIR filter
mask, then override preop()
. Tidying up can be done in
postop()
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Following the existing code as a guide, you will need to add
vipl_filterable_section_container_generator_NEW_IMAGE_TYPE
This is needed to provide details about your image type to the filter.
vipl_accessors_NEW_IMAGE_TYPE
This provides implementations of setpixel()
for your image
type, so that all filters can actually read and write your images.
You should provide template instantiations of all the filter classes, accessors, section generators, etc for your filter type. These will not be necessary if you use automatic template instantiation, and you do not commit your code into the vxl repository.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on May, 1 2013 using texi2html 1.76.