Package net.sourceforge.jiu.data
Interface ShortChannelImage
-
- All Superinterfaces:
IntegerImage
,PixelImage
- All Known Subinterfaces:
Gray16Image
,RGB48Image
- All Known Implementing Classes:
MemoryGray16Image
,MemoryRGB48Image
,MemoryShortChannelImage
public interface ShortChannelImage extends IntegerImage
An extension of theIntegerImage
interface that restricts the image toshort
samples. The minimum sample value for all channels is0
, the maximum sample value65535
(216 - 1).Number of channels and resolution must be given to the constructor and cannot be changed after creation.
Each channel of the image is made up of
short
values. Note that shorts in Java are signed, they can take values from-32768
to32767
. If you useIntegerImage
's getSample and putSample methods you don't have to deal with this, you always getint
samples that are in the 0 .. 65535 interval.To manually convert a Java
short
value to anint
value in the range of 0 to 65535, do the following:short s = ...; // initialize short value int i = s & 0xffff; // i now is a value between 0 and 65535
- Since:
- 0.11.0
- Author:
- Marco Schmidt
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description 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.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 channelIndex, int x, int y, int w, int h, short[] dest, int destOffset)
Copies samples from this image to a short array.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 (index0
) 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.-
Methods inherited from interface net.sourceforge.jiu.data.IntegerImage
clear, clear, getMaxSample, getSample, getSample, getSamples, putSample, putSample, putSamples
-
Methods inherited from interface net.sourceforge.jiu.data.PixelImage
createCompatibleImage, createCopy, getAllocatedMemory, getBitsPerPixel, getHeight, getImageType, getNumChannels, getWidth
-
-
-
-
Method Detail
-
clear
void clear(short newValue)
Sets all samples of the first channel to the argument short value. Equal toclear(0, newValue);
.- Parameters:
newValue
- all samples in the first channel are set to this value- See Also:
clear(int, short)
,IntegerImage.clear(int)
,IntegerImage.clear(int, int)
-
clear
void clear(int channelIndex, short newValue)
Sets all samples of one channel to a new value.- Parameters:
channelIndex
- zero-based index of the channel to be cleared (must be smaller thanPixelImage.getNumChannels()
newValue
- all samples in the channel will be set to this value
-
getShortSample
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 asgetShortSample(0, x, y)
.- Parameters:
x
- horizontal position of the sample to be returned (must be between0
andPixelImage.getWidth()
- 1
y
- vertical position of the sample to be returned (must be between0
andPixelImage.getHeight()
- 1
- Returns:
- the requested short sample
-
getShortSample
short getShortSample(int channel, int x, int y)
Returns a single short sample from the image. When possible, try copying several samples at a time for higher speed (getShortSamples(int, int, int, int, int, short[], int)
).- Parameters:
channel
- the number of the channel of the sample; must be from0
toPixelImage.getNumChannels()
- 1x
- the column of the sample to be returned; must be from0
toPixelImage.getWidth()
- 1y
- the row of the sample; must be from0
toPixelImage.getHeight()
- 1- Returns:
- the sample, a single short value
- Throws:
IllegalArgumentException
- if the arguments hurt one of the preconditions above- See Also:
getShortSamples(int, int, int, int, int, short[], int)
-
getShortSamples
void getShortSamples(int channelIndex, int x, int y, int w, int h, short[] dest, int destOffset)
Copies samples from this image to a short array. Copiesnum
samples in rowy
of channelchannel
, starting at horizontal offsetx
. Data will be written to thedest
array, starting at offsetdestOffset
. Data will be copied from one row only, so a maximum ofgetWidth()
samples can be copied with a call to this method.- Parameters:
channelIndex
- the index of the channel to be copied from; must be from0
togetNumChannels() - 1
x
- the horizontal offset where copying will start; must be from0
togetWidth() - 1
y
- the row from which will be copied; must be from0
togetHeight() - 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 leastdestOffset + num
destOffset
- the offset intodest
where this method will start copying data- Throws:
IllegalArgumentException
- if the arguments hurt one of the many preconditions above
-
putShortSample
void putShortSample(int channel, int x, int y, short newValue)
Sets one short sample in one channel to a new value.
-
putShortSample
void putShortSample(int x, int y, short newValue)
Sets one short sample in the first channel (index0
) to a new value. Result is equal toputShortSample(0, x, y, newValue);
.
-
putShortSamples
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.
-
-