1@chapsummary
2Image Processing is fairly (but not very) important in Computer Vision.
3@endchapsummary
4
5@section Usage of vipl
6
7vipl provides several image processing algorithms including
8mathematical morphology, smoothing, edge filtering. All of these
9algorithms are provided as filter classes. So there is a
10@code{vipl_gaussian_convolution} class, etc.
11
12The pattern for using each filter is as follows.
13
14@example
15vipl_filtering_operation<TEMPLATE TYPES> op(parameters);
16op.put_in_data_ptr(src_image_ptr);
17op.put_out_data_ptr(dst_image_ptr);
18op.filter();
19@end example
20
21The TEMPLATE TYPES and parameters depend on the actual operation.
22Common template parameters include the types of the source image,
23the destination image, the source pixels, the destination pixels,
24and the pixel iterator. So a concrete use might be:
25
26@example
27typedef vil_memory_image im_type;
28im_type src(width,height,1,VIL_PIXEL_FORMAT_BYTE), dest;
29...
30vipl_gaussian_convolution<im_type,im_type,vxl_byte,vxl_byte,vipl_trivial_pixeliter> op(2.0);
31op.put_in_data_ptr(&src);
32op.put_out_data_ptr(&dest);
33op.filter();
34@end example
35
36All of the concrete classes depend on an abstract class tree
37including vipl_filter<>, which automatically provides the ability
38to work on images that are too large to be fit into memory in one
39go.
40
41@subsection Available filters
42
43The following concrete operations have been implemented so far
44
45
46@subsubsection Morphological operators
47
48@itemize @bullet
49@item vipl_dilate_disk
50@item vipl_erode_disk
51@item vipl_median
52@end itemize
53
54@subsubsection Pixel-wise operations
55
56@itemize @bullet
57@item vipl_convert
58@item vipl_add_random_noise
59@item vipl_threshold
60@item vipl_monadic
61@item vipl_dyadic
62@end itemize
63
64@subsection FIR filters
65
66@itemize @bullet
67@item vipl_gaussian_convolution
68@item vipl_gradient_dir
69@item vipl_gradient_mag
70@item vipl_x_gradient
71@item vipl_y_gradient
72@item vipl_sobel
73@end itemize
74
75
76@subsection Others
77
78@itemize @bullet
79@item vipl_histogram
80@item vipl_moment
81@end itemize
82
83@section Implementation of new filtering operations. (Developer topic)
84
85
86It is probably easiest to follow an example. However, the basic
87minimum required is to override @code{section_applyop()}. It
88should scan through the whole section, and set the output
89accordingly. For example
90
91@example
92template <class ImgIn,class ImgOut,class DataIn,class DataOut,class PixelItr>
93bool vipl_gradient_dir <ImgIn,ImgOut,DataIn,DataOut,PixelItr> :: section_applyop()
94@{
95  const ImgIn &in = in_data(0);
96  ImgOut &out = *out_data_ptr();
97
98  DataIn dummy = DataIn(); register double dx, dy;
99  int startx = start(X_Axis());
100  int starty = start(Y_Axis());
101  int stopx = stop(X_Axis());
102  int stopy = stop(Y_Axis());
103  for (int j = starty; j < stopy; ++j)
104    for (int i = startx; i < stopx; ++i)
105    @{
106      dx = fgetpixel(in, i, j, dummy) - getpixel(in, i-1, j, dummy);
107      dy = fgetpixel(in, i, j, dummy) - getpixel(in, i, j-1, dummy);
108      dx = (vcl_atan2( dy, dx ) + shift()) * scale();
109      fsetpixel(out, i, j, (DataOut)dx);
110    @}
111  return true;
112@}
113@end example
114
115Use of the @code{start()}, @code{stop()}, @code{X_Axis()},
116@code{getpixel()}, @code{setpixel()}, etc. inline functions means
117that your new filter will work with any image type that vipl
118supports.
119
120If you need to pre-calculate something, such as an FIR filter
121mask, then override @code{preop()}. Tidying up can be done in
122@code{postop()}.
123
124
125@section Using a new image type with vipl. (Developer topic)
126
127Following the existing code as a guide, you will need to add
128@itemize @bullet
129
130@item
131@code{vipl_filterable_section_container_generator_NEW_IMAGE_TYPE}
132
133This is needed to provide details about your image type to the
134filter.
135
136@item @code{vipl_accessors_NEW_IMAGE_TYPE}
137
138This provides implementations of @code{setpixel()} for your image
139type, so that all filters can actually read and write your images.
140
141@item Template instantiations
142
143You should provide template instantiations of all the filter
144classes, accessors, section generators, etc for your filter type.
145These will not be necessary if you use automatic template
146instantiation, and you do not commit your code into the @vxl{}
147repository.
148@end itemize
149