Class GradientCalculator
- java.lang.Object
-
- edu.gsu.cs.dmlab.imageproc.edgedetection.GradientCalculator
-
- All Implemented Interfaces:
IGradientCalculator
public class GradientCalculator extends Object implements IGradientCalculator
A class for calculating the gradient of pixel intensities on source images. This class uses different kernels, depending on the provided gradient operator name, and calculated both horizontal and vertical derivatives, as well as the magnitude and angle of changes in the color intensity of pixels.
Pass the string "prewitt" to its constructor to apply Prewitt operator or "sobel" to apply Sobel operator.
There exists other operators which have not been yet implemented in this class:
- Roberts operator
- Laplacian operator
- Author:
- Azim Ahmadzadeh, updated by Dustin Kempton, Data Mining Lab, Georgia State University
-
-
Constructor Summary
Constructors Constructor Description GradientCalculator(String gradientName)
This constructor sets the gradient operator based on the given name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Gradient
calculateGradientCart(double[][] image)
Calculates the gradient of pixel intensities on the input image and returns the results in the original Cartesian coordinate system.Gradient
calculateGradientPolar(double[][] image)
Calculates the gradient of pixel intensities on the input image and returns the results in a Polar coordinate system
-
-
-
Constructor Detail
-
GradientCalculator
public GradientCalculator(String gradientName)
This constructor sets the gradient operator based on the given name.- Parameters:
gradientName
- name of the gradient operator among the following options:- "prewitt": Prewitt operator
- "sobel": Sobel operator
-
-
Method Detail
-
calculateGradientPolar
public Gradient calculateGradientPolar(double[][] image)
Description copied from interface:IGradientCalculator
Calculates the gradient of pixel intensities on the input image and returns the results in a Polar coordinate system- Specified by:
calculateGradientPolar
in interfaceIGradientCalculator
- Parameters:
image
- The input image in the form of a 2D array of doubles- Returns:
- The gradient as gx=theta and gy=r
The range of theta is (-3.14, +3.14)
-
calculateGradientCart
public Gradient calculateGradientCart(double[][] image)
Description copied from interface:IGradientCalculator
Calculates the gradient of pixel intensities on the input image and returns the results in the original Cartesian coordinate system.- Specified by:
calculateGradientCart
in interfaceIGradientCalculator
- Parameters:
image
- The input image in the form of a 2D array of doubles- Returns:
- The gradient in x and y direction
-
-