#include <gradient.h>
Inheritance diagram for iptk::Gradient:
I(m,n)
be an image.
Then gradient image is calculated using:
Gx(m, n) = I(m+1, n) - I(m, n),
Gy(m, n) = I(m, n+1) - I(m, n),
G(m, n) = sqrt(Gx(m, n)^2 + Gy(m, n)^2),
and the direction is calculated using:
The gradient operation simultaneously generates a 'direction map'. In generating the direction map, it is assumed that slope can be only in one of the eight directions as shown below:
6 | 7 | 8 |
5 | X | 1 |
4 | 3 | 2 |
The direction map is an array as large as the image and each cell stores the direction number corresponding to the direction of the gradient at the location. The registered image is not disturbed in this process. A new image, with its own memory space, holds the calculated gradient.
NOTE: An RGB image would be converted to a gray-scale image in this process of gradient determination.
Public Member Functions | |
Gradient (void) | |
Default constructor. | |
Gradient (const iptk::Image &im) | |
Image registering constructor. | |
Gradient (const Gradient &g) | |
Copy constructor Though this constructor does not look like a reference copier, the image data is shared between the passed object(i.e the parameter to the copy constructor) and the new object. | |
virtual | ~Gradient () |
Do nothing destructor. | |
virtual void | process (void) |
A virtual function to process the image. | |
TNT::Array2D< int > | getDirectionMap (void) |
Returns the direction map as an object of type tsip::Matrix. | |
virtual iptk::Image | getResult (void) |
Returns the gradient image. | |
Protected Attributes | |
TNT::Array2D< int > | dirMap |
Protected data member to hold the direction map. |
|
Default constructor. An object created using the default constructor should set the image by using the setImage member function. |
|
Image registering constructor. The image is autmatically registered at the construction stage and processed in place. |
|
Do nothing destructor. Destructor does nothing at all as the default destructor would have been sufficient. |
|
Returns the direction map as an object of type tsip::Matrix. See the class description above for more information on direction maps. |
|
Returns the gradient image. This image has its own memory different from the registered image. Reimplemented from iptk::IP_Function. Reimplemented in iptk::PrewittGradient, iptk::RobertGradient, iptk::SobelGradient, iptk::SteepestAscent, and iptk::SteepestDescent. |
|
A virtual function to process the image. This function actually performs the gradient operation on the registered image. The result is stored in a new memory location and can be accessed by the getResult member function. The image registered is un-affected by this process. Implements iptk::IP_Function. Reimplemented in iptk::PrewittGradient, iptk::RobertGradient, iptk::SobelGradient, iptk::SteepestAscent, and iptk::SteepestDescent. |
|
Protected data member to hold the direction map. Refer to the TNT documentation for more information. |