IntegerImage
, PixelImage
, ShortChannelImage
MemoryGray16Image
, MemoryRGB48Image
public abstract class MemoryShortChannelImage extends Object implements ShortChannelImage
ShortChannelImage
that stores image channels as
short[]
arrays in memory.
An image can have an arbitrary number of channels.
This class is abstract because it is merely a data container.
It takes a subclass like MemoryGray16Image
to give meaning to the values.
Modifier and Type | Field | Description |
---|---|---|
private short[][] |
data |
|
private short[] |
firstChannel |
|
private int |
height |
|
private int |
numChannels |
|
private int |
numPixels |
|
private int |
width |
Constructor | Description |
---|---|
MemoryShortChannelImage(int numChannels,
int width,
int height) |
Create an image of short channels.
|
Modifier and Type | Method | Description |
---|---|---|
protected void |
checkPositionAndNumber(int channel,
int x,
int y,
int w,
int h) |
Throws an exception if the arguments do not form a valid horizontal
sequence of samples.
|
void |
clear(int newValue) |
Sets all samples in the first channel to the argument value.
|
void |
clear(int channelIndex,
int newValue) |
Sets all samples of the
channelIndex 'th channel to newValue . |
void |
clear(int channelIndex,
short newValue) |
Sets all samples of one channel to a new value.
|
void |
clear(short newValue) |
Sets all samples of the first channel to the argument short value.
|
abstract PixelImage |
createCompatibleImage(int width,
int height) |
Creates an instance of the same class as this one, with width and height
given by the arguments.
|
PixelImage |
createCopy() |
Creates an new image object that will be of the same type as this one,
with the same image data, using entirely new resources.
|
long |
getAllocatedMemory() |
Returns the number of bytes that were dynamically allocated for
this image object.
|
int |
getBitsPerPixel() |
Returns the number of bits per pixel of this image.
|
int |
getHeight() |
Returns the vertical resolution of the image in pixels.
|
int |
getMaxSample(int channel) |
Returns the maximum value for one of the image's channels.
|
int |
getNumChannels() |
Returns the number of channels in this image.
|
int |
getSample(int x,
int y) |
Returns one sample of the first channel (index 0).
|
int |
getSample(int channel,
int x,
int y) |
Returns one sample, specified by its channel index and location.
|
void |
getSamples(int channel,
int x,
int y,
int w,
int h,
int[] dest,
int destOffs) |
Copies a number of samples from this image to an
int[] object. |
short |
getShortSample(int x,
int y) |
Returns a single short sample from the first channel and the specified position.
|
short |
getShortSample(int channel,
int x,
int y) |
Returns a single short sample from the image.
|
void |
getShortSamples(int channel,
int x,
int y,
int w,
int h,
short[] dest,
int destOffset) |
Copies samples from this image to a short array.
|
int |
getWidth() |
Returns the horizontal resolution of the image in pixels.
|
void |
putSample(int x,
int y,
int newValue) |
This method sets one sample of the first channel (index 0) to a new value.
|
void |
putSample(int channel,
int x,
int y,
int newValue) |
This method sets one sample to a new value.
|
void |
putSamples(int channel,
int x,
int y,
int w,
int h,
int[] src,
int srcOffs) |
Copies a number of samples from an
int[] array to this image. |
void |
putShortSample(int channel,
int x,
int y,
short newValue) |
Sets one short sample in one channel to a new value.
|
void |
putShortSample(int x,
int y,
short newValue) |
Sets one short sample in the first channel (index
0 ) to a new value. |
void |
putShortSamples(int channel,
int x,
int y,
int w,
int h,
short[] src,
int srcOffset) |
Copies a number of samples from the argument array to this image.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getImageType
private final short[][] data
private final short[] firstChannel
private final int numChannels
private final int width
private final int height
private final int numPixels
public MemoryShortChannelImage(int numChannels, int width, int height)
width * height * numChannels * 2
bytes.numChannels
- the number of channels in this image, must be
larger than zerowidth
- the horizontal resolution, must be larger than zeroheight
- the vertical resolution, must be larger than zeroprotected void checkPositionAndNumber(int channel, int x, int y, int w, int h)
public void clear(short newValue)
ShortChannelImage
clear(0, newValue);
.clear
in interface ShortChannelImage
newValue
- all samples in the first channel are set to this valueShortChannelImage.clear(int, short)
,
IntegerImage.clear(int)
,
IntegerImage.clear(int, int)
public void clear(int channelIndex, short newValue)
ShortChannelImage
clear
in interface ShortChannelImage
channelIndex
- zero-based index of the channel to be cleared (must be smaller than PixelImage.getNumChannels()
newValue
- all samples in the channel will be set to this valuepublic void clear(int newValue)
IntegerImage
clear(0, newValue);
:clear
in interface IntegerImage
public void clear(int channelIndex, int newValue)
IntegerImage
channelIndex
'th channel to newValue
.clear
in interface IntegerImage
public abstract PixelImage createCompatibleImage(int width, int height)
PixelImage
createCompatibleImage
in interface PixelImage
width
- the horizontal resolution of the new imageheight
- the vertical resolution of the new imagepublic PixelImage createCopy()
PixelImage
createCopy
in interface PixelImage
public long getAllocatedMemory()
PixelImage
getAllocatedMemory
in interface PixelImage
public int getBitsPerPixel()
PixelImage
getBitsPerPixel
in interface PixelImage
public short getShortSample(int channel, int x, int y)
ShortChannelImage
ShortChannelImage.getShortSamples(int, int, int, int, int, short[], int)
).getShortSample
in interface ShortChannelImage
channel
- the number of the channel of the sample; must be from 0
to PixelImage.getNumChannels()
- 1
x
- the column of the sample to be returned; must be from 0
to PixelImage.getWidth()
- 1
y
- the row of the sample; must be from 0
to PixelImage.getHeight()
- 1
ShortChannelImage.getShortSamples(int, int, int, int, int, short[], int)
public short getShortSample(int x, int y)
ShortChannelImage
getShortSample(0, x, y)
.getShortSample
in interface ShortChannelImage
x
- horizontal position of the sample to be returned (must be between 0
and PixelImage.getWidth()
- 1
y
- vertical position of the sample to be returned (must be between 0
and PixelImage.getHeight()
- 1
public void getShortSamples(int channel, int x, int y, int w, int h, short[] dest, int destOffset)
ShortChannelImage
num
samples in row y
of channel
channel
, starting at horizontal offset x
.
Data will be written to the dest
array, starting at
offset destOffset
.
Data will be copied from one row only, so a maximum of
getWidth()
samples can be copied with a call to this method.getShortSamples
in interface ShortChannelImage
channel
- the index of the channel to be copied from; must be
from 0
to getNumChannels() - 1
x
- the horizontal offset where copying will start; must be from
0
to getWidth() - 1
y
- the row from which will be copied; must be from
0
to getHeight() - 1
w
- number of columns to be copiedh
- number of rows to be copieddest
- the array where the data will be copied to; must have a
length of at least destOffset + num
destOffset
- the offset into dest
where this method
will start copying datapublic final int getHeight()
PixelImage
getHeight
in interface PixelImage
public int getMaxSample(int channel)
IntegerImage
0
.getMaxSample
in interface IntegerImage
channel
- zero-based index of the channel, from 0
to PixelImage.getNumChannels()
- 1
public int getNumChannels()
PixelImage
getNumChannels
in interface PixelImage
public final int getSample(int x, int y)
IntegerImage
getSample(0, x, y);
.getSample
in interface IntegerImage
x
- the horizontal position of the sample, from 0
to PixelImage.getWidth()
- 1
y
- the vertical position of the sample, from 0
to PixelImage.getHeight()
- 1
public final int getSample(int channel, int x, int y)
IntegerImage
getSample
in interface IntegerImage
channel
- the number of the channel, from 0
to PixelImage.getNumChannels()
- 1
x
- the horizontal position of the sample, from 0
to PixelImage.getWidth()
- 1
y
- the vertical position of the sample, from 0
to PixelImage.getHeight()
- 1
public void getSamples(int channel, int x, int y, int w, int h, int[] dest, int destOffs)
IntegerImage
int[]
object.
A rectangular part of one channel is copied.
The channel index is given by - the upper left corner of
that rectangle is given by the point x / y.
Width and height of that rectangle are given by w and h.
Each sample will be stored as one int
value dest,
starting at index destOffs.getSamples
in interface IntegerImage
channel
- zero-based index of the channel from which data is to be copied (valid values: 0 to PixelImage.getNumChannels()
- 1)x
- horizontal position of upper left corner of the rectangle to be copiedy
- vertical position of upper left corner of the rectangle to be copiedw
- width of rectangle to be copiedh
- height of rectangle to be copieddest
- int array to which the samples will be copieddestOffs
- int index into the dest array for the position to which the samples will be copiedpublic final int getWidth()
PixelImage
getWidth
in interface PixelImage
public final void putShortSample(int channel, int x, int y, short newValue)
ShortChannelImage
putShortSample
in interface ShortChannelImage
public final void putShortSample(int x, int y, short newValue)
ShortChannelImage
0
) to a new value.
Result is equal to putShortSample(0, x, y, newValue);
.putShortSample
in interface ShortChannelImage
public void putShortSamples(int channel, int x, int y, int w, int h, short[] src, int srcOffset)
ShortChannelImage
putShortSamples
in interface ShortChannelImage
public void putSamples(int channel, int x, int y, int w, int h, int[] src, int srcOffs)
IntegerImage
int[]
array to this image.
A rectangular part of one channel is copied - the upper left corner of
that rectangle is given by the point x / y.
Width and height of that rectangle are given by w and h.
Each sample will be stored as one int
value src,
starting at index srcOffset.putSamples
in interface IntegerImage
channel
- int (from 0 to getNumChannels() - 1) to indicate the channel to which data is copiedx
- horizontal position of upper left corner of the rectangle to be copiedy
- vertical position of upper left corner of the rectangle to be copiedw
- width of rectangle to be copiedh
- height of rectangle to be copiedsrc
- int array from which the samples will be copiedsrcOffs
- int index into the src array for the position from which the samples will be copiedpublic final void putSample(int x, int y, int newValue)
IntegerImage
putSample(0, x, y)
.
The sample location is given by the spatial coordinates, x and y.putSample
in interface IntegerImage
x
- the horizontal position of the sample, from 0
to PixelImage.getWidth()
- 1
y
- the vertical position of the sample, from 0
to PixelImage.getHeight()
- 1
newValue
- the new value of the samplepublic final void putSample(int channel, int x, int y, int newValue)
IntegerImage
putSample
in interface IntegerImage
channel
- the number of the channel, from 0
to PixelImage.getNumChannels()
- 1
x
- the horizontal position of the sample, from 0
to PixelImage.getWidth()
- 1
y
- the vertical position of the sample, from 0
to PixelImage.getHeight()
- 1
newValue
- the new value of the sample