Class BinaryFast
- java.lang.Object
-
- org.hortonmachine.gears.modules.utils.BinaryFast
-
public class BinaryFast extends Object
Class BinaryFast is a representation of a binary image storing the foreground and background edge pixels in hash tables for efficiency.- Author:
- Simon Horne., Andrea Antonello (www.hydrologis.com)
-
-
Field Summary
Fields Modifier and Type Field Description static intBACKGROUNDBackground is black.static intFOREGROUNDForeground is white.
-
Constructor Summary
Constructors Constructor Description BinaryFast(int[][] data)Create aBinaryFastobject based on a data matrix.BinaryFast(RenderedImage renderedImage)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPixel(Point p)Adds a foreground pixel to the 2D array by setting its value to foreground.int[]convertToArray()Converts the 2D array into a 1D array of pixel values.voidconvertToPixels(HashSet<Point> pix)Adds the pixels from a hash set to the 2D array of pixels.voidgenerateBackgroundEdgeFromForegroundEdge()Generates the background edge hash set from the foreground edge hash set and the 2D array of pixels.voidgenerateForegroundEdge()Generates the foreground edge hash set from the 2D array of pixels.voidgenerateForegroundEdgeFromBackgroundEdge()Generates the foreground edge hash set from the background edge hash set and the 2D array of pixels.voidgeneratePixels(HashSet<Point> pix)Generates a new 2D array of pixels from a hash set of foreground pixels.HashSet<Point>getBackgroundEdgePixels()HashSet<Point>getForegroundEdgePixels()intgetHeight()int[][]getPixels()int[]getValues()Returns the int [] values of the Binary Fast imageintgetWidth()voidremovePixel(Point p)Removes a foreground pixel from the 2D array by setting its value to background.
-
-
-
Field Detail
-
BACKGROUND
public static final int BACKGROUND
Background is black.- See Also:
- Constant Field Values
-
FOREGROUND
public static final int FOREGROUND
Foreground is white.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BinaryFast
public BinaryFast(int[][] data)
Create aBinaryFastobject based on a data matrix.Note that the matrix cycles over matrix[i][j], where i = columns and j = rows.
- Parameters:
data- the data matrix already inFOREGROUND,BACKGROUNDmode.
-
BinaryFast
public BinaryFast(RenderedImage renderedImage)
-
-
Method Detail
-
removePixel
public void removePixel(Point p)
Removes a foreground pixel from the 2D array by setting its value to background.- Parameters:
p- The point to be removed.
-
addPixel
public void addPixel(Point p)
Adds a foreground pixel to the 2D array by setting its value to foreground.- Parameters:
p- The point to be added.
-
convertToArray
public int[] convertToArray()
Converts the 2D array into a 1D array of pixel values.- Returns:
- The 1D array of pixel values.
-
generatePixels
public void generatePixels(HashSet<Point> pix)
Generates a new 2D array of pixels from a hash set of foreground pixels.- Parameters:
pix- The hash set of foreground pixels.
-
convertToPixels
public void convertToPixels(HashSet<Point> pix)
Adds the pixels from a hash set to the 2D array of pixels.- Parameters:
pix- The hash set of foreground pixels to be added.
-
generateForegroundEdge
public void generateForegroundEdge()
Generates the foreground edge hash set from the 2D array of pixels.
-
generateBackgroundEdgeFromForegroundEdge
public void generateBackgroundEdgeFromForegroundEdge()
Generates the background edge hash set from the foreground edge hash set and the 2D array of pixels.
-
generateForegroundEdgeFromBackgroundEdge
public void generateForegroundEdgeFromBackgroundEdge()
Generates the foreground edge hash set from the background edge hash set and the 2D array of pixels.
-
getValues
public int[] getValues()
Returns the int [] values of the Binary Fast image- Returns:
- int[] the greylevel array of the image
-
getPixels
public int[][] getPixels()
-
getWidth
public int getWidth()
-
getHeight
public int getHeight()
-
-