当前位置: 首页>>代码示例>>Java>>正文


Java PixelAccessor.getPixels方法代码示例

本文整理汇总了Java中javax.media.jai.PixelAccessor.getPixels方法的典型用法代码示例。如果您正苦于以下问题:Java PixelAccessor.getPixels方法的具体用法?Java PixelAccessor.getPixels怎么用?Java PixelAccessor.getPixels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.media.jai.PixelAccessor的用法示例。


在下文中一共展示了PixelAccessor.getPixels方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: floatLoop

import javax.media.jai.PixelAccessor; //导入方法依赖的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);
   }
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:30,代码来源:BinarizeOpImage.java

示例2: doubleLoop

import javax.media.jai.PixelAccessor; //导入方法依赖的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);
   }
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:30,代码来源:BinarizeOpImage.java

示例3: warpSparseRect

import javax.media.jai.PixelAccessor; //导入方法依赖的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;
}
 
开发者ID:senbox-org,项目名称:s2tbx,代码行数:48,代码来源:WarpFromSourceCoordinates.java

示例4: byteLoop

import javax.media.jai.PixelAccessor; //导入方法依赖的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);
   }
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:45,代码来源:BinarizeOpImage.java

示例5: shortLoop

import javax.media.jai.PixelAccessor; //导入方法依赖的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);
   }
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:45,代码来源:BinarizeOpImage.java

示例6: ushortLoop

import javax.media.jai.PixelAccessor; //导入方法依赖的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);
   }
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:45,代码来源:BinarizeOpImage.java

示例7: intLoop

import javax.media.jai.PixelAccessor; //导入方法依赖的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);
   }
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:47,代码来源:BinarizeOpImage.java

示例8: computeHistogram

import javax.media.jai.PixelAccessor; //导入方法依赖的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;
        }
    }
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:54,代码来源:MedianCutOpImage.java

示例9: constructTree

import javax.media.jai.PixelAccessor; //导入方法依赖的package包/类
private void constructTree(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:
            constructTreeByte(uid);
            break;
        }
    }
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:53,代码来源:OctTreeOpImage.java

示例10: byteLoop

import javax.media.jai.PixelAccessor; //导入方法依赖的package包/类
private void byteLoop(Raster[] sources,
                      WritableRaster dest,
                      Rectangle destRect) {
    int nSrcs = sources.length;
    int[] snbands = new int[nSrcs];
    PixelAccessor[] pas = new PixelAccessor[nSrcs];

    for ( int i = 0; i < nSrcs; i++ ) {
        pas[i] = new PixelAccessor(sources[i].getSampleModel(), colorModels[i]);

        if ( colorModels[i] instanceof IndexColorModel ) {
            snbands[i] = colorModels[i].getNumComponents();
        } else {
            snbands[i] = sources[i].getNumBands();
        }
    }        

    int dnbands     = dest.getNumBands();
    int destType    = dest.getTransferType();
    PixelAccessor d = new PixelAccessor(dest.getSampleModel(), null);

    UnpackedImageData dimd = d.getPixels(dest,
                                         destRect,    //liney,
                                         destType,
                                         true);

    byte[][] dstdata = (byte[][])dimd.data;

    for ( int sindex = 0, db = 0; sindex < nSrcs; sindex++ ) {

        UnpackedImageData simd =
            colorModels[sindex] instanceof IndexColorModel ?
            pas[sindex].getComponents(sources[sindex],
                                      destRect,
                                      sources[sindex].getSampleModel().getTransferType()) :
            pas[sindex].getPixels(sources[sindex],
                                  destRect,
                                  sources[sindex].getSampleModel().getTransferType(),
                                  false);

          
        int srcPixelStride = simd.pixelStride;
        int srcLineStride  = simd.lineStride;
        int dstPixelStride = dimd.pixelStride;
        int dstLineStride  = dimd.lineStride;
        int dRectWidth     = destRect.width;

        for ( int sb = 0; sb < snbands[sindex]; sb++, db++ ) {
            if ( db >= dnbands ) {
                 // exceeding destNumBands; should not have happened
                 break; 
            }

            byte[]   dstdatabandb = dstdata[db];
            byte[][] srcdata = (byte[][])simd.data;
            byte[]   srcdatabandsb = srcdata[sb];
            int srcstart = simd.bandOffsets[sb];
            int dststart = dimd.bandOffsets[db];

            for(int y = 0;
                y < destRect.height;
                y++, srcstart += srcLineStride, dststart += dstLineStride){
                
                for(int i=0, srcpos = srcstart, dstpos = dststart;
                    i < dRectWidth;
                    i++, srcpos += srcPixelStride, dstpos += dstPixelStride){
                      
                         dstdatabandb[dstpos] = srcdatabandsb[srcpos];
                }
            }
        }
    }

    d.setPixels(dimd);
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:76,代码来源:BandMergeOpImage.java

示例11: shortLoop

import javax.media.jai.PixelAccessor; //导入方法依赖的package包/类
private void shortLoop(Raster[] sources,
                       WritableRaster dest,
                       Rectangle destRect) {
    int nSrcs = sources.length;
    int[] snbands = new int[nSrcs];
    PixelAccessor[] pas = new PixelAccessor[nSrcs];

    for ( int i = 0; i < nSrcs; i++ ) {
        pas[i] = new PixelAccessor(sources[i].getSampleModel(), colorModels[i]);

        if ( colorModels[i] instanceof IndexColorModel ) {
            snbands[i] = colorModels[i].getNumComponents();
        } else {
            snbands[i] = sources[i].getNumBands();
        }
    }        

    int dnbands     = dest.getNumBands();
    int destType    = dest.getTransferType();
    PixelAccessor d = new PixelAccessor(dest.getSampleModel(),null);

    UnpackedImageData dimd = d.getPixels(dest,
                                         destRect,    //liney,
                                         destType,
                                         true);

    short[][] dstdata = (short[][])dimd.data;

    for ( int sindex = 0, db = 0; sindex < nSrcs; sindex++ ) {

        UnpackedImageData simd =
            colorModels[sindex] instanceof IndexColorModel ?
            pas[sindex].getComponents(sources[sindex],
                                      destRect,
                                      sources[sindex].getSampleModel().getTransferType()) :
            pas[sindex].getPixels(sources[sindex],
                                  destRect,
                                  sources[sindex].getSampleModel().getTransferType(),
                                  false);
          
        int srcPixelStride = simd.pixelStride;
        int srcLineStride  = simd.lineStride;
        int dstPixelStride = dimd.pixelStride;
        int dstLineStride  = dimd.lineStride;
        int dRectWidth     = destRect.width;

        for ( int sb = 0; sb < snbands[sindex]; sb++, db++ ) {
            if ( db < dnbands ) {
                short[][] srcdata = (short[][])simd.data;
                int srcstart = simd.bandOffsets[sb];
                int dststart = dimd.bandOffsets[db];
                for(int y = 0;
                    y < destRect.height;
                    y++, srcstart += srcLineStride, dststart += dstLineStride){
                    
                    for(int i=0, srcpos = srcstart, dstpos = dststart;
                        i < dRectWidth;
                        i++, srcpos += srcPixelStride, dstpos += dstPixelStride){
                      
                            dstdata[db][dstpos] = srcdata[sb][srcpos];
                    }
                }
            }
        }
    }

    d.setPixels(dimd);
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:69,代码来源:BandMergeOpImage.java

示例12: intLoop

import javax.media.jai.PixelAccessor; //导入方法依赖的package包/类
private void intLoop(Raster[] sources,
                     WritableRaster dest,
                     Rectangle destRect) {
    int nSrcs = sources.length;
    int[] snbands = new int[nSrcs];
    PixelAccessor[] pas = new PixelAccessor[nSrcs];

    for ( int i = 0; i < nSrcs; i++ ) {
        pas[i] = new PixelAccessor(sources[i].getSampleModel(), colorModels[i]);

        if ( colorModels[i] instanceof IndexColorModel ) {
            snbands[i] = colorModels[i].getNumComponents();
        } else {
            snbands[i] = sources[i].getNumBands();
        }
    }        

    int dnbands     = dest.getNumBands();
    int destType    = dest.getTransferType();
    PixelAccessor d = new PixelAccessor(dest.getSampleModel(),null);

    UnpackedImageData dimd = d.getPixels(dest,
                                         destRect,    //liney,
                                         destType,
                                         true);

    int[][] dstdata = (int[][])dimd.data;

    for ( int sindex = 0, db = 0; sindex < nSrcs; sindex++ ) {

        UnpackedImageData simd =
            colorModels[sindex] instanceof IndexColorModel ?
            pas[sindex].getComponents(sources[sindex],
                                      destRect,
                                      sources[sindex].getSampleModel().getTransferType()) :
            pas[sindex].getPixels(sources[sindex],
                                  destRect,
                                  sources[sindex].getSampleModel().getTransferType(),
                                  false);

        int srcPixelStride = simd.pixelStride;
        int srcLineStride  = simd.lineStride;
        int dstPixelStride = dimd.pixelStride;
        int dstLineStride  = dimd.lineStride;
        int dRectWidth     = destRect.width;

        for ( int sb = 0; sb < snbands[sindex]; sb++, db++ ) {
            if ( db < dnbands ) {
                int[][] srcdata = (int[][])simd.data;
                int srcstart = simd.bandOffsets[sb];
                int dststart = dimd.bandOffsets[db];
                for(int y = 0;
                    y < destRect.height;
                    y++, srcstart += srcLineStride, dststart += dstLineStride){
                    
                    for(int i=0, srcpos = srcstart, dstpos = dststart;
                        i < dRectWidth;
                        i++, srcpos += srcPixelStride, dstpos += dstPixelStride){
                       
                            dstdata[db][dstpos] = srcdata[sb][srcpos];
                    }
                }
            }
        }
    }

    d.setPixels(dimd);
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:69,代码来源:BandMergeOpImage.java

示例13: floatLoop

import javax.media.jai.PixelAccessor; //导入方法依赖的package包/类
private void floatLoop(Raster[] sources,
                       WritableRaster dest,
                       Rectangle destRect) {

    int nSrcs = sources.length;
    int[] snbands = new int[nSrcs];
    PixelAccessor[] pas = new PixelAccessor[nSrcs];

    for ( int i = 0; i < nSrcs; i++ ) {
        pas[i] = new PixelAccessor(sources[i].getSampleModel(), colorModels[i]);

        if ( colorModels[i] instanceof IndexColorModel ) {
            snbands[i] = colorModels[i].getNumComponents();
        } else {
            snbands[i] = sources[i].getNumBands();
        }
    }        

    int dnbands     = dest.getNumBands();
    int destType    = dest.getTransferType();
    PixelAccessor d = new PixelAccessor(dest.getSampleModel(), null);

    UnpackedImageData dimd = d.getPixels(dest,
                                         destRect,    //liney,
                                         destType,
                                         true);

    float[][] dstdata = (float[][])dimd.data;

    for ( int sindex = 0, db = 0; sindex < nSrcs; sindex++ ) {

        UnpackedImageData simd =
            colorModels[sindex] instanceof IndexColorModel ?
            pas[sindex].getComponents(sources[sindex],
                                      destRect,
                                      sources[sindex].getSampleModel().getTransferType()) :
            pas[sindex].getPixels(sources[sindex],
                                  destRect,
                                  sources[sindex].getSampleModel().getTransferType(),
                                  false);

        int srcPixelStride = simd.pixelStride;
        int srcLineStride  = simd.lineStride;
        int dstPixelStride = dimd.pixelStride;
        int dstLineStride  = dimd.lineStride;
        int dRectWidth     = destRect.width;

        for ( int sb = 0; sb < snbands[sindex]; sb++, db++ ) {
            if ( db < dnbands ) {
                float[][] srcdata = (float[][])simd.data;
                int srcstart = simd.bandOffsets[sb];
                int dststart = dimd.bandOffsets[db];
                for(int y = 0;
                    y < destRect.height;
                    y++, srcstart += srcLineStride, dststart += dstLineStride){
                    
                    for(int i=0, srcpos = srcstart, dstpos = dststart;
                        i < dRectWidth;
                        i++, srcpos += srcPixelStride, dstpos += dstPixelStride){
                       
                            dstdata[db][dstpos] = srcdata[sb][srcpos];
                    }
                }
            }
        }
    }

    d.setPixels(dimd);
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:70,代码来源:BandMergeOpImage.java

示例14: doubleLoop

import javax.media.jai.PixelAccessor; //导入方法依赖的package包/类
private void doubleLoop(Raster[] sources,
                      WritableRaster dest,
                      Rectangle destRect) {

    int nSrcs = sources.length;
    int[] snbands = new int[nSrcs];
    PixelAccessor[] pas = new PixelAccessor[nSrcs];

    for ( int i = 0; i < nSrcs; i++ ) {
        pas[i] = new PixelAccessor(sources[i].getSampleModel(), colorModels[i]);

        if ( colorModels[i] instanceof IndexColorModel ) {
            snbands[i] = colorModels[i].getNumComponents();
        } else {
            snbands[i] = sources[i].getNumBands();
        }
    }        

    int dnbands     = dest.getNumBands();
    int destType    = dest.getTransferType();
    PixelAccessor d = new PixelAccessor(dest.getSampleModel(), null);

    UnpackedImageData dimd = d.getPixels(dest,
                                         destRect,    //liney,
                                         destType,
                                         true);

    double[][] dstdata = (double[][])dimd.data;

    for ( int sindex = 0, db = 0; sindex < nSrcs; sindex++ ) {

        UnpackedImageData simd =
            colorModels[sindex] instanceof IndexColorModel ?
            pas[sindex].getComponents(sources[sindex],
                                      destRect,
                                      sources[sindex].getSampleModel().getTransferType()) :
            pas[sindex].getPixels(sources[sindex],
                                  destRect,
                                  sources[sindex].getSampleModel().getTransferType(),
                                  false);

        int srcPixelStride = simd.pixelStride;
        int srcLineStride  = simd.lineStride;
        int dstPixelStride = dimd.pixelStride;
        int dstLineStride  = dimd.lineStride;
        int dRectWidth     = destRect.width;

        for ( int sb = 0; sb < snbands[sindex]; sb++, db++ ) {
            if ( db < dnbands ) {
                double[][] srcdata = (double[][])simd.data;
                int srcstart = simd.bandOffsets[sb];
                int dststart = dimd.bandOffsets[db];
                for(int y = 0;
                    y < destRect.height;
                    y++, srcstart += srcLineStride, dststart += dstLineStride){
                    
                    for(int i=0, srcpos = srcstart, dstpos = dststart;
                        i < dRectWidth;
                        i++, srcpos += srcPixelStride, dstpos += dstPixelStride){
                       
                            dstdata[db][dstpos] = srcdata[sb][srcpos];
                    }
                }
            }
        }
    }

    d.setPixels(dimd);
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:70,代码来源:BandMergeOpImage.java


注:本文中的javax.media.jai.PixelAccessor.getPixels方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。