Package javax.media.jai

Examples of javax.media.jai.PixelAccessor


                               WritableRaster dest,
                               Rectangle destRect) {

        Raster source = sources[0];

  PixelAccessor pa = new PixelAccessor(source.getSampleModel(), null);
  PackedImageData srcIm =
            pa.getPackedPixels(source, source.getBounds(), false, false);

  pa = new PixelAccessor(dest.getSampleModel(), null);
  PackedImageData dstIm =
            pa.getPackedPixels(dest, destRect, true, false);

        // src data under kernel, packed in int.
  int[] srcUK = new int [kwPack * kh];

  // sliding the kernel row by row
  // general the packed matrix under the row
  int dheight = destRect.height;
  int dwidth  = destRect.width;

  int sOffset = srcIm.offset;
  int dOffset = dstIm.offset;
  for (int j = 0; j < dheight; j++) {
            int selement, val, dindex, delement;

      // reset srcUK for each row beginning
      // src[sOffset +[-kx:kw-kx, -ky:kh-ky]] placed in srcUK
      //
      for (int m = 0; m < srcUK.length; m++){
          srcUK[m] = 0;
      }
     
      // initial srcUK
      // first shift left the packed bits under the sliding kernel by 1 bit
      // then fill (compute) in the last bit of each row
      for(int i = 0; i < kw -1; i++){
          bitShiftMatrixLeft(srcUK, kh, kwPack); // expand for speedup?
    int lastCol = kwPack - 1;
    int bitLoc  = srcIm.bitOffset + i;
    int byteLoc = bitLoc >> 3;
    bitLoc = 7 - (bitLoc & 7);
    for(int m=0, sOffsetB = sOffset;
        m < kh;
        m++, sOffsetB += srcIm.lineStride){

      selement = (int)srcIm.data[sOffsetB + byteLoc];
      val = (selement >> bitLoc) & 0x1;
      srcUK[lastCol] |= val;
      lastCol += kwPack;
    }
      }

      // same as above
      // also setting dest
      for (int i = 0; i < dwidth; i++){

          bitShiftMatrixLeft(srcUK, kh, kwPack); // expand for speedup?
    int lastCol = kwPack - 1;
    int bitLoc  = srcIm.bitOffset + i + kw -1;
    int byteLoc = bitLoc >> 3;
    bitLoc = 7 - (bitLoc & 7);
    for(int m=0, sOffsetB = sOffset;
        m < kh;
        m++, sOffsetB += srcIm.lineStride){

      selement = (int)srcIm.data[sOffsetB + byteLoc];
      val = (selement >> bitLoc) & 0x1;
      srcUK[lastCol] |= val;
      lastCol += kwPack;
    }

    // set dest bits
    for (int m = 0; m < srcUK.length; m++){
        if ((srcUK[m] & kdataPack[m]) != 0){
              int dBitLoc = dstIm.bitOffset + i;
          int dshift  = 7 - (dBitLoc & 7);
          int dByteLoc= (dBitLoc >> 3) + dOffset;
          delement  = (int)dstIm.data[dByteLoc];
          delement |= (0x1) << dshift;
          dstIm.data[dByteLoc] = (byte)delement;
          break;
        }
    }

      }
            sOffset += srcIm.lineStride;
            dOffset += dstIm.lineStride;
        }
  pa.setPackedPixels(dstIm);
    }
View Full Code Here


                               WritableRaster dest,
                               Rectangle destRect) {

        Raster source = sources[0];

  PixelAccessor pa = new PixelAccessor(source.getSampleModel(), null);
  PackedImageData srcIm =
            pa.getPackedPixels(source, source.getBounds(), false, false);

  pa = new PixelAccessor(dest.getSampleModel(), null);
  PackedImageData dstIm =
            pa.getPackedPixels(dest, destRect, true, false);

        // src data under kernel, packed in int.
  int[] srcUK = new int [kwPack * kh];

  // sliding the kernel row by row
  // general the packed matrix under the row
  int dheight = destRect.height;
  int dwidth  = destRect.width;

  int sOffset = srcIm.offset;
  int dOffset = dstIm.offset;
  for (int j = 0; j < dheight; j++) {
            int selement, val, dindex, delement;

      // reset srcUK for each row beginning
      // src[sOffset +[-kx:kw-kx, -ky:kh-ky]] placed in srcUK
      //
      for (int m = 0; m < srcUK.length; m++){
          srcUK[m] = 0;
      }
     
      // initial srcUK
      // first shift left the packed bits under the sliding kernel by 1 bit
      // then fill (compute) in the last bit of each row
      for(int i = 0; i < kw -1; i++){
          bitShiftMatrixLeft(srcUK, kh, kwPack); // expand for speedup?
    int lastCol = kwPack - 1;
    int bitLoc  = srcIm.bitOffset + i;
    int byteLoc = bitLoc >> 3;
    bitLoc = 7 - (bitLoc & 7);
    for(int m=0, sOffsetB = sOffset;
        m < kh;
        m++, sOffsetB += srcIm.lineStride){

      selement = (int)srcIm.data[sOffsetB + byteLoc];
      val = (selement >> bitLoc) & 0x1;
      srcUK[lastCol] |= val;
      lastCol += kwPack;
    }
      }

      // same as above
      // also setting dest
      for (int i = 0; i < dwidth; i++){

          bitShiftMatrixLeft(srcUK, kh, kwPack); // expand for speedup?
    int lastCol = kwPack - 1;
    int bitLoc  = srcIm.bitOffset + i + kw -1;
    int byteLoc = bitLoc >> 3;
    bitLoc = 7 - (bitLoc & 7);
    for(int m=0, sOffsetB = sOffset;
        m < kh;
        m++, sOffsetB += srcIm.lineStride){

      selement = (int)srcIm.data[sOffsetB + byteLoc];
      val = (selement >> bitLoc) & 0x1;
      srcUK[lastCol] |= val;
      lastCol += kwPack;
    }


    int dBitLoc = dstIm.bitOffset + i;
    int dshift  = 7 - (dBitLoc & 7);
    int dByteLoc= (dBitLoc >> 3) + dOffset;
    delement  = (int)dstIm.data[dByteLoc];
    delement |= (0x1) << dshift;

    for (int m = 0; m < srcUK.length; m++){
        if ((srcUK[m] & kdataPack[m]) != kdataPack[m]){
          delement &= ~((0x1) << dshift);
          break;
        }
    }
    dstIm.data[dByteLoc] = (byte)delement;
      }
            sOffset += srcIm.lineStride;
            dOffset += dstIm.lineStride;
        }
  pa.setPackedPixels(dstIm);
    }
View Full Code Here

                            Rectangle destRect) {
        if (colorMap == null)
            train();

        if(!isInitialized) {
            srcPA = new PixelAccessor(getSourceImage(0));
            srcSampleType = srcPA.sampleType == PixelAccessor.TYPE_BIT ?
                DataBuffer.TYPE_BYTE : srcPA.sampleType;
            isInitialized = true;
        }

        UnpackedImageData uid =
            srcPA.getPixels(sources[0], destRect,
                            srcSampleType, false);
        Rectangle rect = uid.rect;
        byte[][] data = uid.getByteData();
        int srcLineStride = uid.lineStride;
        int srcPixelStride = uid.pixelStride;
        byte[] rBand = data[0];
        byte[] gBand = data[1];
        byte[] bBand = data[2];

        int lastLine = rect.height * srcLineStride + uid.bandOffsets[0];

        if (destPA == null)
            destPA = new PixelAccessor(this);

        UnpackedImageData destUid =
            destPA.getPixels(dest, destRect,
                             sampleModel.getDataType(), false);

View Full Code Here

    protected void accumulateStatistics(String name,
                                        Raster source,
                                        Object stats) {
        if(!isInitialized) {
            srcPA = new PixelAccessor(getSourceImage(0));
            srcSampleType = srcPA.sampleType == PixelAccessor.TYPE_BIT ?
                DataBuffer.TYPE_BYTE : srcPA.sampleType;
            isInitialized = true;
        }
View Full Code Here

            }
        }

        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;
            }
View Full Code Here

/*     */     }
/*     */   }
/*     */
/*     */   private void byteLoop(Raster source, WritableRaster dest, Rectangle destRect)
/*     */   {
/* 433 */     PixelAccessor pa = new PixelAccessor(source.getSampleModel(), null);
/* 434 */     PackedImageData pid = pa.getPackedPixels(source, source.getBounds(), false, false);
/*     */
/* 436 */     byte[] sourceData = pid.data;
/* 437 */     int sourceDBOffset = pid.offset;
/* 438 */     int dx = destRect.x; int dy = destRect.y;
/* 439 */     int dwi = destRect.width; int dhi = destRect.height;
View Full Code Here

/* 165 */     setProperty("LUT", this.colorMap);
/*     */   }
/*     */
/*     */   private void computeHistogram(Raster source) {
/* 169 */     if (!this.isInitialized) {
/* 170 */       this.srcPA = new PixelAccessor(getSourceImage(0));
/* 171 */       this.srcSampleType = (this.srcPA.sampleType == -1 ? 0 : this.srcPA.sampleType);
/*     */
/* 173 */       this.isInitialized = true;
/*     */     }
/*     */
View Full Code Here

/*     */   }
/*     */
/*     */   protected void accumulateStatistics(String name, Raster source, Object stats)
/*     */   {
/* 115 */     if (!this.isInitialized) {
/* 116 */       this.srcPA = new PixelAccessor(getSourceImage(0));
/* 117 */       this.srcSampleType = (this.srcPA.sampleType == -1 ? 0 : this.srcPA.sampleType);
/*     */
/* 120 */       this.totalPixelValue = new double[this.srcPA.numBands];
/* 121 */       this.totalPixelCount = 0;
/* 122 */       this.isInitialized = true;
View Full Code Here

/*     */     }
/*     */   }
/*     */
/*     */   private void byteLoop(Raster source, WritableRaster dest, Rectangle destRect)
/*     */   {
/* 475 */     PixelAccessor pa = new PixelAccessor(source.getSampleModel(), null);
/* 476 */     PackedImageData pid = pa.getPackedPixels(source, source.getBounds(), false, false);
/*     */
/* 478 */     byte[] sourceData = pid.data;
/* 479 */     int sourceDBOffset = pid.offset;
/* 480 */     int dx = destRect.x;
/* 481 */     int dy = destRect.y;
View Full Code Here

/* 261 */       return false;
/*     */     }
/*     */
/* 267 */     RenderedImage src = (RenderedImage)args.getSource(0);
/*     */
/* 269 */     PixelAccessor srcPA = new PixelAccessor(src);
/* 270 */     if ((!srcPA.isPacked) || (!srcPA.isMultiPixelPackedSM)) {
/* 271 */       msg.append(getName() + " " + JaiI18N.getString("SubsampleBinaryToGray3"));
/*     */
/* 273 */       return false;
/*     */     }
View Full Code Here

TOP

Related Classes of javax.media.jai.PixelAccessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.