public abstract class MemoryShortChannelImage extends java.lang.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 and Description |
|---|---|
private short[][] |
data |
private short[] |
firstChannel |
private int |
height |
private int |
numChannels |
private int |
numPixels |
private int |
width |
| Constructor and Description |
|---|
MemoryShortChannelImage(int numChannels,
int width,
int height)
Create an image of short channels.
|
| Modifier and Type | Method and 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, waitgetImageTypeprivate 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)
ShortChannelImageclear(0, newValue);.clear in interface ShortChannelImagenewValue - 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)
ShortChannelImageclear in interface ShortChannelImagechannelIndex - 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)
IntegerImageclear(0, newValue);:clear in interface IntegerImagepublic void clear(int channelIndex,
int newValue)
IntegerImagechannelIndex'th channel to newValue.clear in interface IntegerImagepublic abstract PixelImage createCompatibleImage(int width, int height)
PixelImagecreateCompatibleImage in interface PixelImagewidth - the horizontal resolution of the new imageheight - the vertical resolution of the new imagepublic PixelImage createCopy()
PixelImagecreateCopy in interface PixelImagepublic long getAllocatedMemory()
PixelImagegetAllocatedMemory in interface PixelImagepublic int getBitsPerPixel()
PixelImagegetBitsPerPixel in interface PixelImagepublic short getShortSample(int channel,
int x,
int y)
ShortChannelImageShortChannelImage.getShortSamples(int, int, int, int, int, short[], int)).getShortSample in interface ShortChannelImagechannel - the number of the channel of the sample; must be from 0 to PixelImage.getNumChannels() - 1x - the column of the sample to be returned; must be from 0 to PixelImage.getWidth() - 1y - the row of the sample; must be from 0 to PixelImage.getHeight() - 1ShortChannelImage.getShortSamples(int, int, int, int, int, short[], int)public short getShortSample(int x,
int y)
ShortChannelImagegetShortSample(0, x, y).getShortSample in interface ShortChannelImagex - horizontal position of the sample to be returned (must be between 0 and PixelImage.getWidth() - 1y - vertical position of the sample to be returned (must be between 0 and PixelImage.getHeight() - 1public void getShortSamples(int channel,
int x,
int y,
int w,
int h,
short[] dest,
int destOffset)
ShortChannelImagenum 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 ShortChannelImagechannel - the index of the channel to be copied from; must be
from 0 to getNumChannels() - 1x - the horizontal offset where copying will start; must be from
0 to getWidth() - 1y - the row from which will be copied; must be from
0 to getHeight() - 1w - 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 + numdestOffset - the offset into dest where this method
will start copying datapublic final int getHeight()
PixelImagegetHeight in interface PixelImagepublic int getMaxSample(int channel)
IntegerImage0.getMaxSample in interface IntegerImagechannel - zero-based index of the channel, from 0 to PixelImage.getNumChannels() - 1public int getNumChannels()
PixelImagegetNumChannels in interface PixelImagepublic final int getSample(int x,
int y)
IntegerImagegetSample(0, x, y);.getSample in interface IntegerImagex - the horizontal position of the sample, from 0 to PixelImage.getWidth() - 1y - the vertical position of the sample, from 0 to PixelImage.getHeight() - 1public final int getSample(int channel,
int x,
int y)
IntegerImagegetSample in interface IntegerImagechannel - the number of the channel, from 0 to PixelImage.getNumChannels() - 1x - the horizontal position of the sample, from 0 to PixelImage.getWidth() - 1y - the vertical position of the sample, from 0 to PixelImage.getHeight() - 1public void getSamples(int channel,
int x,
int y,
int w,
int h,
int[] dest,
int destOffs)
IntegerImageint[] 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 IntegerImagechannel - 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()
PixelImagegetWidth in interface PixelImagepublic final void putShortSample(int channel,
int x,
int y,
short newValue)
ShortChannelImageputShortSample in interface ShortChannelImagepublic final void putShortSample(int x,
int y,
short newValue)
ShortChannelImage0) to a new value.
Result is equal to putShortSample(0, x, y, newValue);.putShortSample in interface ShortChannelImagepublic void putShortSamples(int channel,
int x,
int y,
int w,
int h,
short[] src,
int srcOffset)
ShortChannelImageputShortSamples in interface ShortChannelImagepublic void putSamples(int channel,
int x,
int y,
int w,
int h,
int[] src,
int srcOffs)
IntegerImageint[] 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 IntegerImagechannel - 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)
IntegerImageputSample(0, x, y).
The sample location is given by the spatial coordinates, x and y.putSample in interface IntegerImagex - the horizontal position of the sample, from 0 to PixelImage.getWidth() - 1y - the vertical position of the sample, from 0 to PixelImage.getHeight() - 1newValue - the new value of the samplepublic final void putSample(int channel,
int x,
int y,
int newValue)
IntegerImageputSample in interface IntegerImagechannel - the number of the channel, from 0 to PixelImage.getNumChannels() - 1x - the horizontal position of the sample, from 0 to PixelImage.getWidth() - 1y - the vertical position of the sample, from 0 to PixelImage.getHeight() - 1newValue - the new value of the sample