An implementation of
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.
checkPositionAndNumber
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.
To be valid, all of the following requirements must be met:
clear
public void clear(int channelIndex,
int newValue)- clear in interface IntegerImage
clear
public void clear(int channelIndex,
short newValue) Sets all samples of one channel to a new value.
- clear in interface ShortChannelImage
channelIndex - zero-based index of the channel to be cleared (must be smaller than getNumChannels()newValue - all samples in the channel will be set to this value
clear
public void clear(short newValue)
Sets all samples of the first channel to the argument short value.
Equal to clear(0, newValue);.
- clear in interface ShortChannelImage
newValue - all samples in the first channel are set to this value
getSamples
public void getSamples(int channel,
int x,
int y,
int w,
int h,
int[] dest,
int destOffs)- getSamples in interface IntegerImage
getShortSample
public short getShortSample(int x,
int y) Returns a single short sample from the first channel and the specified position.
A call to this method is the same as getShortSample(0, x, y).
- getShortSample in interface ShortChannelImage
x - horizontal position of the sample to be returned (must be between 0 and getWidth() - 1y - vertical position of the sample to be returned (must be between 0 and getHeight() - 1
- the requested short sample
getShortSample
public short getShortSample(int channel,
int x,
int y)- getShortSample in interface ShortChannelImage
channel - the number of the channel of the sample; must be from 0 to getNumChannels() - 1x - the column of the sample to be returned; must be from 0 to getWidth() - 1y - the row of the sample; must be from 0 to getHeight() - 1
- the sample, a single short value
getShortSamples
public 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.
Copies 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
x - 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 data
putSample
public final void putSample(int channel,
int x,
int y,
int newValue)- putSample in interface IntegerImage
putSamples
public void putSamples(int channel,
int x,
int y,
int w,
int h,
int[] src,
int srcOffs)- putSamples in interface IntegerImage
putShortSample
public final void putShortSample(int channel,
int x,
int y,
short newValue) Sets one short sample in one channel to a new value.
- putShortSample in interface ShortChannelImage
putShortSample
public final void putShortSample(int x,
int y,
short newValue) Sets one short sample in the first channel (index 0) to a new value.
Result is equal to putShortSample(0, x, y, newValue);.
- putShortSample in interface ShortChannelImage
putShortSamples
public 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.
- putShortSamples in interface ShortChannelImage