本文整理汇总了Java中javax.media.jai.UnpackedImageData类的典型用法代码示例。如果您正苦于以下问题:Java UnpackedImageData类的具体用法?Java UnpackedImageData怎么用?Java UnpackedImageData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnpackedImageData类属于javax.media.jai包,在下文中一共展示了UnpackedImageData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: accumulateStatisticsByte
import javax.media.jai.UnpackedImageData; //导入依赖的package包/类
private void accumulateStatisticsByte(UnpackedImageData uid) {
Rectangle rect = uid.rect;
byte[][] data = uid.getByteData();
int lineStride = uid.lineStride;
int pixelStride = uid.pixelStride;
int lineInc = lineStride * yPeriod;
int pixelInc = pixelStride * xPeriod;
for (int b = 0; b < srcPA.numBands; b++) {
byte[] d = data[b];
int lastLine = uid.bandOffsets[b] + rect.height * lineStride;
for (int lo = uid.bandOffsets[b]; lo < lastLine; lo += lineInc) {
int lastPixel = lo + rect.width * pixelStride;
for (int po = lo; po < lastPixel; po += pixelInc) {
totalPixelValue[b] += d[po] & 0xff;
}
}
}
totalPixelCount += (int)Math.ceil((double)rect.height / yPeriod) *
(int)Math.ceil((double)rect.width / xPeriod);
}
示例2: accumulateStatisticsUShort
import javax.media.jai.UnpackedImageData; //导入依赖的package包/类
private void accumulateStatisticsUShort(UnpackedImageData uid) {
Rectangle rect = uid.rect;
short[][] data = uid.getShortData();
int lineStride = uid.lineStride;
int pixelStride = uid.pixelStride;
int lineInc = lineStride * yPeriod;
int pixelInc = pixelStride * xPeriod;
for (int b = 0; b < srcPA.numBands; b++) {
short[] d = data[b];
int lastLine = uid.bandOffsets[b] + rect.height * lineStride;
for (int lo = uid.bandOffsets[b]; lo < lastLine; lo += lineInc) {
int lastPixel = lo + rect.width * pixelStride;
for (int po = lo; po < lastPixel; po += pixelInc) {
totalPixelValue[b] += d[po] & 0xffff;
}
}
}
totalPixelCount += (int)Math.ceil((double)rect.height / yPeriod) *
(int)Math.ceil((double)rect.width / xPeriod);
}
示例3: accumulateStatisticsShort
import javax.media.jai.UnpackedImageData; //导入依赖的package包/类
private void accumulateStatisticsShort(UnpackedImageData uid) {
Rectangle rect = uid.rect;
short[][] data = uid.getShortData();
int lineStride = uid.lineStride;
int pixelStride = uid.pixelStride;
int lineInc = lineStride * yPeriod;
int pixelInc = pixelStride * xPeriod;
for (int b = 0; b < srcPA.numBands; b++) {
short[] d = data[b];
int lastLine = uid.bandOffsets[b] + rect.height * lineStride;
for (int lo = uid.bandOffsets[b]; lo < lastLine; lo += lineInc) {
int lastPixel = lo + rect.width * pixelStride;
for (int po = lo; po < lastPixel; po += pixelInc) {
totalPixelValue[b] += d[po];
}
}
}
totalPixelCount += (int)Math.ceil((double)rect.height / yPeriod) *
(int)Math.ceil((double)rect.width / xPeriod);
}
示例4: accumulateStatisticsInt
import javax.media.jai.UnpackedImageData; //导入依赖的package包/类
private void accumulateStatisticsInt(UnpackedImageData uid) {
Rectangle rect = uid.rect;
int[][] data = uid.getIntData();
int lineStride = uid.lineStride;
int pixelStride = uid.pixelStride;
int lineInc = lineStride * yPeriod;
int pixelInc = pixelStride * xPeriod;
for (int b = 0; b < srcPA.numBands; b++) {
int[] d = data[b];
int lastLine = uid.bandOffsets[b] + rect.height * lineStride;
for (int lo = uid.bandOffsets[b]; lo < lastLine; lo += lineInc) {
int lastPixel = lo + rect.width * pixelStride;
for (int po = lo; po < lastPixel; po += pixelInc) {
totalPixelValue[b] += d[po];
}
}
}
totalPixelCount += (int)Math.ceil((double)rect.height / yPeriod) *
(int)Math.ceil((double)rect.width / xPeriod);
}
示例5: accumulateStatisticsFloat
import javax.media.jai.UnpackedImageData; //导入依赖的package包/类
private void accumulateStatisticsFloat(UnpackedImageData uid) {
Rectangle rect = uid.rect;
float[][] data = uid.getFloatData();
int lineStride = uid.lineStride;
int pixelStride = uid.pixelStride;
int lineInc = lineStride * yPeriod;
int pixelInc = pixelStride * xPeriod;
for (int b = 0; b < srcPA.numBands; b++) {
float[] d = data[b];
int lastLine = uid.bandOffsets[b] + rect.height * lineStride;
for (int lo = uid.bandOffsets[b]; lo < lastLine; lo += lineInc) {
int lastPixel = lo + rect.width * pixelStride;
for (int po = lo; po < lastPixel; po += pixelInc) {
totalPixelValue[b] += d[po];
}
}
}
totalPixelCount += (int)Math.ceil((double)rect.height / yPeriod) *
(int)Math.ceil((double)rect.width / xPeriod);
}
示例6: accumulateStatisticsDouble
import javax.media.jai.UnpackedImageData; //导入依赖的package包/类
private void accumulateStatisticsDouble(UnpackedImageData uid) {
Rectangle rect = uid.rect;
double[][] data = uid.getDoubleData();
int lineStride = uid.lineStride;
int pixelStride = uid.pixelStride;
int lineInc = lineStride * yPeriod;
int pixelInc = pixelStride * xPeriod;
for (int b = 0; b < srcPA.numBands; b++) {
double[] d = data[b];
int lastLine = uid.bandOffsets[b] + rect.height * lineStride;
for (int lo = uid.bandOffsets[b]; lo < lastLine; lo += lineInc) {
int lastPixel = lo + rect.width * pixelStride;
for (int po = lo; po < lastPixel; po += pixelInc) {
totalPixelValue[b] += d[po];
}
}
}
totalPixelCount += (int)Math.ceil((double)rect.height / yPeriod) *
(int)Math.ceil((double)rect.width / xPeriod);
}
示例7: floatLoop
import javax.media.jai.UnpackedImageData; //导入依赖的package包/类
private void floatLoop(Raster source,
WritableRaster dest,
Rectangle destRect){
Rectangle srcRect = mapDestRect(destRect,0); // should be identical to destRect
PixelAccessor pa = new PixelAccessor(dest.getSampleModel(), null);
PackedImageData pid = pa.getPackedPixels(dest, destRect, true, false);
int offset = pid.offset;
PixelAccessor srcPa = new PixelAccessor(source.getSampleModel(), null);
UnpackedImageData srcImD = srcPa.getPixels(source, srcRect, DataBuffer.TYPE_FLOAT, false);
int srcOffset = srcImD.bandOffsets[0];
float[] srcData = ((float[][])srcImD.data)[0];
int pixelStride= srcImD.pixelStride;
int ind0 = pid.bitOffset;
for(int h = 0; h < destRect.height; h++){
int indE = ind0 + destRect.width;
for(int b = ind0, s = srcOffset; b < indE; b++, s += pixelStride){
if (srcData[s]>threshold) {
pid.data[offset + (b >> 3)] |= byteTable[b%8];
}
}
offset += pid.lineStride;
srcOffset += srcImD.lineStride;
}
pa.setPackedPixels(pid);
}
示例8: doubleLoop
import javax.media.jai.UnpackedImageData; //导入依赖的package包/类
private void doubleLoop(Raster source,
WritableRaster dest,
Rectangle destRect){
Rectangle srcRect = mapDestRect(destRect,0); // should be identical to destRect
PixelAccessor pa = new PixelAccessor(dest.getSampleModel(), null);
PackedImageData pid = pa.getPackedPixels(dest, destRect, true, false);
int offset = pid.offset;
PixelAccessor srcPa = new PixelAccessor(source.getSampleModel(), null);
UnpackedImageData srcImD = srcPa.getPixels(source, srcRect, DataBuffer.TYPE_DOUBLE, false);
int srcOffset = srcImD.bandOffsets[0];
double[] srcData = ((double[][])srcImD.data)[0];
int pixelStride= srcImD.pixelStride;
int ind0 = pid.bitOffset;
for(int h = 0; h < destRect.height; h++){
int indE = ind0 + destRect.width;
for(int b = ind0, s = srcOffset; b < indE; b++, s += pixelStride){
if (srcData[s]>threshold) {
pid.data[offset + (b >> 3)] |= byteTable[b%8];
}
}
offset += pid.lineStride;
srcOffset += srcImD.lineStride;
}
pa.setPackedPixels(pid);
}
示例9: computeHistogramByte
import javax.media.jai.UnpackedImageData; //导入依赖的package包/类
private void computeHistogramByte(UnpackedImageData uid) {
Rectangle rect = uid.rect;
byte[][] data = uid.getByteData();
int lineStride = uid.lineStride;
int pixelStride = uid.pixelStride;
byte[] rBand = data[0];
byte[] gBand = data[1];
byte[] bBand = data[2];
int lineInc = lineStride * yPeriod;
int pixelInc = pixelStride * xPeriod;
int lastLine = rect.height * lineStride;
for (int lo = 0; lo < lastLine; lo += lineInc) {
int lastPixel = lo + rect.width * pixelStride;
for (int po = lo; po < lastPixel; po += pixelInc) {
int p = ((rBand[po + uid.bandOffsets[0]] & 0xff)<<16) |
((gBand[po + uid.bandOffsets[1]] & 0xff) <<8) |
(bBand[po + uid.bandOffsets[2]] & 0xff);
if (!histogram.insert(p & mask)) {
bits--;
return;
}
}
}
}
示例10: warpSparseRect
import javax.media.jai.UnpackedImageData; //导入依赖的package包/类
/**
* Computes the source pixel positions for a given rectangular
* destination region, subsampled with an integral period.
*/
@Override
public float[] warpSparseRect(int xmin, int ymin, int width, int height, int periodX, int periodY, float[] destRect) {
if (periodX < 1) throw new IllegalArgumentException(String.valueOf(periodX));
if (periodY < 1) throw new IllegalArgumentException(String.valueOf(periodY));
final int xmax = xmin + width;
final int ymax = ymin + height;
final int count = ((width+(periodX-1))/periodX) * ((height+(periodY-1))/periodY);
if (destRect == null) {
destRect = new float[2*count];
}
Rectangle bounds = new Rectangle(xmin, ymin, width, height);
int xIDNew = opImage.XToTileX(xmin);
int yIDNew = opImage.YToTileY(ymin);
Raster tile = opImage.getTile(xIDNew, yIDNew);
if (!tile.getBounds().contains(bounds)) {
// Dont'n know why, but JAI can call with "width" or "height" == 0
return destRect;
}
PixelAccessor accessor = new PixelAccessor(opImage);
UnpackedImageData srcImD = accessor.getPixels(tile, bounds, DataBuffer.TYPE_FLOAT, false);
float[] data = srcImD.getFloatData(0);
int sxStart = srcImD.bandOffsets[0];
int syStart = srcImD.bandOffsets[1];
int pixelStride = srcImD.pixelStride;
int lineStride = srcImD.lineStride;
int index = 0;
for (int y=ymin; y<ymax; y+=periodY) {
int sxPos = sxStart;
int syPos = syStart;
for (int x=xmin; x<xmax; x+=periodX) {
destRect[index++] = data[sxPos];
destRect[index++] = data[syPos];
sxPos += pixelStride;
syPos += pixelStride;
}
sxStart += lineStride;
syStart += lineStride;
}
return destRect;
}
示例11: byteLoop
import javax.media.jai.UnpackedImageData; //导入依赖的package包/类
private void byteLoop(Raster source,
WritableRaster dest,
Rectangle destRect){
if(threshold <= 0.0D){
// every bit is 1
setTo1(dest, destRect);
return;
}else if (threshold > 255.0D){
//every bit is zeros;
return;
}
short thresholdI = (short)Math.ceil(threshold);
// computation can be done in integer
// even though threshold is of double type
// int thresholdI = (int)Math.ceil(this.threshold);
// or through a lookup table for byte case
Rectangle srcRect = mapDestRect(destRect,0); // should be identical to destRect
PixelAccessor pa = new PixelAccessor(dest.getSampleModel(), null);
PackedImageData pid = pa.getPackedPixels(dest, destRect, true, false);
int offset = pid.offset;
PixelAccessor srcPa = new PixelAccessor(source.getSampleModel(), null);
UnpackedImageData srcImD = srcPa.getPixels(source, srcRect, DataBuffer.TYPE_BYTE, false);
int srcOffset = srcImD.bandOffsets[0];
byte[] srcData = ((byte[][])srcImD.data)[0];
int pixelStride= srcImD.pixelStride;
int ind0 = pid.bitOffset;
for(int h = 0; h < destRect.height; h++){
int indE = ind0 + destRect.width;
for(int b = ind0, s = srcOffset; b < indE; b++, s += pixelStride){
if((srcData[s]&0xFF) >= thresholdI) {
pid.data[offset + (b >> 3)] |= byteTable[b%8];
}
}
offset += pid.lineStride;
srcOffset += srcImD.lineStride;
}
pa.setPackedPixels(pid);
}
示例12: shortLoop
import javax.media.jai.UnpackedImageData; //导入依赖的package包/类
private void shortLoop(Raster source,
WritableRaster dest,
Rectangle destRect){
if(threshold <= Short.MIN_VALUE){
// every bit is 1
setTo1(dest, destRect);
return;
}else if (threshold > Short.MAX_VALUE){
//every bit is zeros;
return;
}
short thresholdS = (short)( Math.ceil(threshold));
// computation can be done in integer
// even though threshold is of double type
// int thresholdI = (int)Math.ceil(this.threshold);
// or through a lookup table for byte case
Rectangle srcRect = mapDestRect(destRect,0); // should be identical to destRect
PixelAccessor pa = new PixelAccessor(dest.getSampleModel(), null);
PackedImageData pid = pa.getPackedPixels(dest, destRect, true, false);
int offset = pid.offset;
PixelAccessor srcPa = new PixelAccessor(source.getSampleModel(), null);
UnpackedImageData srcImD = srcPa.getPixels(source, srcRect, DataBuffer.TYPE_SHORT, false);
int srcOffset = srcImD.bandOffsets[0];
short[] srcData = ((short[][])srcImD.data)[0];
int pixelStride= srcImD.pixelStride;
int ind0 = pid.bitOffset;
for(int h = 0; h < destRect.height; h++){
int indE = ind0 + destRect.width;
for(int b = ind0, s = srcOffset; b < indE; b++, s += pixelStride){
if(srcData[s] >= thresholdS) {
pid.data[offset + (b >> 3)] |= byteTable[b%8];
}
}
offset += pid.lineStride;
srcOffset += srcImD.lineStride;
}
pa.setPackedPixels(pid);
}
示例13: ushortLoop
import javax.media.jai.UnpackedImageData; //导入依赖的package包/类
private void ushortLoop(Raster source,
WritableRaster dest,
Rectangle destRect){
if(threshold <= 0.0D){
// every bit is 1
setTo1(dest, destRect);
return;
}else if (threshold > (double)(0xFFFF)){
//every bit is zeros;
return;
}
int thresholdI = (int)( Math.ceil(threshold));
// computation can be done in integer
// even though threshold is of double type
// int thresholdI = (int)Math.ceil(this.threshold);
// or through a lookup table for byte case
Rectangle srcRect = mapDestRect(destRect,0); // should be identical to destRect
PixelAccessor pa = new PixelAccessor(dest.getSampleModel(), null);
PackedImageData pid = pa.getPackedPixels(dest, destRect, true, false);
int offset = pid.offset;
PixelAccessor srcPa = new PixelAccessor(source.getSampleModel(), null);
UnpackedImageData srcImD = srcPa.getPixels(source, srcRect, DataBuffer.TYPE_USHORT, false);
int srcOffset = srcImD.bandOffsets[0];
short[] srcData = ((short[][])srcImD.data)[0];
int pixelStride= srcImD.pixelStride;
int ind0 = pid.bitOffset;
for(int h = 0; h < destRect.height; h++){
int indE = ind0 + destRect.width;
for(int b = ind0, s = srcOffset; b < indE; b++, s += pixelStride){
if((srcData[s]&0xFFFF) >= thresholdI) {
pid.data[offset + (b >> 3)] |= byteTable[b%8];
}
}
offset += pid.lineStride;
srcOffset += srcImD.lineStride;
}
pa.setPackedPixels(pid);
}
示例14: intLoop
import javax.media.jai.UnpackedImageData; //导入依赖的package包/类
private void intLoop(Raster source,
WritableRaster dest,
Rectangle destRect){
if(threshold <= Integer.MIN_VALUE){
// every bit is 1
setTo1(dest, destRect);
return;
}else if (threshold > (double)Integer.MAX_VALUE){
//every bit is zeros;
return;
}
// computation can be done in integer
// even though threshold is of double type
int thresholdI = (int)Math.ceil(this.threshold);
// computation can be done in integer
// even though threshold is of double type
// int thresholdI = (int)Math.ceil(this.threshold);
Rectangle srcRect = mapDestRect(destRect,0); // should be identical to destRect
PixelAccessor pa = new PixelAccessor(dest.getSampleModel(), null);
PackedImageData pid = pa.getPackedPixels(dest, destRect, true, false);
int offset = pid.offset;
PixelAccessor srcPa = new PixelAccessor(source.getSampleModel(), null);
UnpackedImageData srcImD = srcPa.getPixels(source, srcRect, DataBuffer.TYPE_INT, false);
int srcOffset = srcImD.bandOffsets[0];
int[] srcData = ((int[][])srcImD.data)[0];
int pixelStride= srcImD.pixelStride;
int ind0 = pid.bitOffset;
for(int h = 0; h < destRect.height; h++){
int indE = ind0 + destRect.width;
for(int b = ind0, s = srcOffset; b < indE; b++, s += pixelStride){
if(srcData[s] >= threshold) {
pid.data[offset + (b >> 3)] |= byteTable[b%8];
}
}
offset += pid.lineStride;
srcOffset += srcImD.lineStride;
}
pa.setPackedPixels(pid);
}
示例15: computeHistogram
import javax.media.jai.UnpackedImageData; //导入依赖的package包/类
private void computeHistogram(Raster source) {
if(!isInitialized) {
srcPA = new PixelAccessor(getSourceImage(0));
srcSampleType = srcPA.sampleType == PixelAccessor.TYPE_BIT ?
DataBuffer.TYPE_BYTE : srcPA.sampleType;
isInitialized = true;
}
Rectangle srcBounds = getSourceImage(0).getBounds().intersection(
source.getBounds());
LinkedList rectList;
if (roi == null) { // ROI is the whole Raster
rectList = new LinkedList();
rectList.addLast(srcBounds);
} else {
rectList = roi.getAsRectangleList(srcBounds.x,
srcBounds.y,
srcBounds.width,
srcBounds.height);
if (rectList == null) {
return; // ROI does not intersect with Raster boundary.
}
}
ListIterator iterator = rectList.listIterator(0);
int xStart = source.getMinX();
int yStart = source.getMinY();
while (iterator.hasNext()) {
Rectangle rect = srcBounds.intersection((Rectangle)iterator.next());
int tx = rect.x;
int ty = rect.y;
// Find the actual ROI based on start and period.
rect.x = startPosition(tx, xStart, xPeriod);
rect.y = startPosition(ty, yStart, yPeriod);
rect.width = tx + rect.width - rect.x;
rect.height = ty + rect.height - rect.y;
if (rect.isEmpty()) {
continue; // no pixel to count in this rectangle
}
UnpackedImageData uid = srcPA.getPixels(source, rect,
srcSampleType, false);
switch (uid.type) {
case DataBuffer.TYPE_BYTE:
computeHistogramByte(uid);
break;
}
}
}