General Image Transforms
In the previous chapter, we covered the class of image transformations that can be understood specifically
in terms of convolution. Of course, there are a lot of useful operations that cannot be expressed in this way
(i.e., as a little window scanning over the image doing one thing or another). In general, transformations
that can be expressed as convolutions are local, meaning that even though they may change the entire
image, the effect on any particular pixel is determined by only a small number of pixels around that one.
The transforms we will look in this chapter generally will not have this property.
Some very useful image transforms are very simple, and you will use them all of the timeresize for
example. Others are somewhat more special purpose. In many cases, the image transforms we will look at
in this chapter have the purpose of converting an image into some entirely different representation. This
different representation will usually still be an array of values, but those values might be quite different in
meaning than the intensity values in the input image. An example of this would be the frequency
representation resulting from a Fourier transform. In a few cases, the result of the transformation will be
something like a list of components, as would be the case for the Hough Line Transform.
There are a number of useful transforms that arise repeatedly in computer vision. OpenCV provides
complete implementations of some of the more common ones as well as building blocks to help you
implement your own transformations.
Stretch, Shrink, Warp, and Rotate
The simplest image transforms we will encounter are those that resize an image, either to make it larger or
smaller. These operations are a little less trivial than you might think, because resizing immediately implies
questions about how pixels are interpolated (for enlargement) or merged (for reduction).
Uniform Resize
We often encounter an image of some size that we would like to convert to an image of some other size.
We may want to upsize (zoom in) or downsize (zoom out) the image; both of these tasks are accomplished
by the same function.
The cv::resize() function handles all of our resizing needs. We provide our input image, and the size
we would like it be converted to, and it will generate a new image of exactly the desired size.

Get Learning OpenCV, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.