An implementation of
ByteChannelImage that stores image channels as
byte[] 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
MemoryGray8Image 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(byte newValue)
Sets all samples of the first channel to the argument byte value.
Equal to clear(0, newValue);.
- clear in interface ByteChannelImage
newValue - all samples in the first channel are set to this value
clear
public void clear(int channelIndex,
byte newValue) Sets all samples of one channel to a new value.
- clear in interface ByteChannelImage
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(int channelIndex,
int newValue)- clear in interface IntegerImage
getByteSample
public byte getByteSample(int x,
int y) Returns a single byte sample from the first channel and the specified position.
A call to this method is the same as getByteSample(0, x, y).
- getByteSample in interface ByteChannelImage
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 byte sample
getByteSample
public byte getByteSample(int channel,
int x,
int y)- getByteSample in interface ByteChannelImage
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 byte value
getByteSamples
public void getByteSamples(int channel,
int x,
int y,
int w,
int h,
byte[] dest,
int destOffset) Copies samples from this image to a byte 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.
- getByteSamples in interface ByteChannelImage
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 - the number of columns to be copiedh - the 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
getSamples
public void getSamples(int channel,
int x,
int y,
int w,
int h,
int[] dest,
int destOffs)- getSamples in interface IntegerImage
putByteSample
public final void putByteSample(int x,
int y,
byte newValue) Sets one byte sample in the first channel (index 0) to a new value.
Result is equal to putByteSample(0, x, y, newValue);.
- putByteSample in interface ByteChannelImage
putByteSample
public final void putByteSample(int channel,
int x,
int y,
byte newValue) Sets one byte sample in one channel to a new value.
- putByteSample in interface ByteChannelImage
putByteSamples
public void putByteSamples(int channel,
int x,
int y,
int w,
int h,
byte[] src,
int srcOffset) Copies a number of samples from the argument array to this image.
- putByteSamples in interface ByteChannelImage
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