Top Description Inners Fields Constructors Methods
com.sun.jna.platform

public Class RasterRangesUtils

extends Object
Class Inheritance
Imports
java.awt.Rectangle, java.awt.image.DataBuffer, .DataBufferByte, .DataBufferInt, .MultiPixelPackedSampleModel, .Raster, .SampleModel, .SinglePixelPackedSampleModel, java.util.Collections, .Comparator, .HashSet, .Iterator, .Set, .TreeSet

Methods that are useful to decompose a raster into a set of rectangles. An occupied pixel has two possible meanings, depending on the raster :
Author
Olivier Chafik

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
RasterRangesUtils.RangesOutput

Abstraction of a sink for ranges.

Field Summary

Modifier and TypeField and Description
private static final Comparator<Object>
private static final int[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static Set<Rectangle>
public static boolean

Returns:

true if the output succeeded, false otherwise
outputOccupiedRanges
(Raster
image to be segmented in non black or non-transparent ranges
raster
,
RasterRangesUtils.RangesOutput
destination of the non null ranges
out
)

Outputs ranges of occupied pixels.

public static boolean

Returns:

true if the output succeeded, false otherwise
outputOccupiedRanges
(int[]
integer values of the pixels of an image
pixels
,
int
width of the image (in pixels)
w
,
int
height of the image
h
,
int
mask used to select which bits are used in a pixel to check its occupied status. 0xff000000 would only take the alpha layer into account, for instance.
occupationMask
,
RasterRangesUtils.RangesOutput
where to output all the contiguous ranges of non occupied pixels
out
)

Output the occupied values of an integer-pixels image as ranges of contiguous values.

public static boolean

Returns:

true if the output succeeded, false otherwise
outputOccupiedRangesOfBinaryPixels
(byte[]
byte-packed binary bits of an image
binaryBits
,
int
width of the image (in pixels)
w
,
int
height of the image
h
,
RasterRangesUtils.RangesOutput out)

Output the non-null values of a binary image as ranges of contiguous values.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

COMPARATORback to summary
private static final Comparator<Object> COMPARATOR
subColMasksback to summary
private static final int[] subColMasks

Constructor Detail

RasterRangesUtilsback to summary
public RasterRangesUtils()

Method Detail

mergeRectsback to summary
private static Set<Rectangle> mergeRects(Set<Rectangle> prev, Set<Rectangle> current)
outputOccupiedRangesback to summary
public static boolean outputOccupiedRanges(Raster raster, RasterRangesUtils.RangesOutput out)

Outputs ranges of occupied pixels. In a raster that has an alpha layer, a pixel is occupied if its alpha value is not null. In a raster without alpha layer, a pixel is occupied if it is not completely black.

Parameters
raster:Raster

image to be segmented in non black or non-transparent ranges

out:RasterRangesUtils.RangesOutput

destination of the non null ranges

Returns:boolean

true if the output succeeded, false otherwise

outputOccupiedRangesback to summary
public static boolean outputOccupiedRanges(int[] pixels, int w, int h, int occupationMask, RasterRangesUtils.RangesOutput out)

Output the occupied values of an integer-pixels image as ranges of contiguous values. A pixel is considered occupied if the bitwise AND of its integer value with the provided occupationMask is not null.

Parameters
pixels:int[]

integer values of the pixels of an image

w:int

width of the image (in pixels)

h:int

height of the image

occupationMask:int

mask used to select which bits are used in a pixel to check its occupied status. 0xff000000 would only take the alpha layer into account, for instance.

out:RasterRangesUtils.RangesOutput

where to output all the contiguous ranges of non occupied pixels

Returns:boolean

true if the output succeeded, false otherwise

outputOccupiedRangesOfBinaryPixelsback to summary
public static boolean outputOccupiedRangesOfBinaryPixels(byte[] binaryBits, int w, int h, RasterRangesUtils.RangesOutput out)

Output the non-null values of a binary image as ranges of contiguous values.

Parameters
binaryBits:byte[]

byte-packed binary bits of an image

w:int

width of the image (in pixels)

h:int

height of the image

Returns:boolean

true if the output succeeded, false otherwise

com.sun.jna.platform back to summary

public Interface RasterRangesUtils.RangesOutput


Abstraction of a sink for ranges.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the output succeeded, false otherwise
outputRange
(int
x coordinate of the top-left corner of the range
x
,
int
y coordinate of the top-left corner of the range
y
,
int
width of the range
w
,
int
height of the range
h
)

Output a rectangular range.

Method Detail

outputRangeback to summary
public boolean outputRange(int x, int y, int w, int h)

Output a rectangular range.

Parameters
x:int

x coordinate of the top-left corner of the range

y:int

y coordinate of the top-left corner of the range

w:int

width of the range

h:int

height of the range

Returns:boolean

true if the output succeeded, false otherwise