Package org.jwildfire.image

Examples of org.jwildfire.image.Pixel


        if (x1 < 0)
          x1 = 0;
        int x2 = col - dx + blockWidth;
        if (x2 > imgWidth - dx)
          x2 = imgWidth - dx;
        Pixel p = block.computeAVGColor(pImg, x1, x2, y1, y2);
        if (!filteredByGenlock(p)) {
          block.prepareTransformation(blockScale, blockScaleVariance, blockAngleAlpha, blockAngleBeta, blockAngleVariance);
          block.createBlock(pImg, x1, x2, y1, y2, zsize2, p.getARGBValue());
          block.transformBlock(x1, x2, y1, y2, xMin, yMin);
          block.addToMainStructure(x, y, z, pp1, pp2, pp3, color, currP, currF);
          currF += block.getFCount();
          currP += block.getPCount();
        }
View Full Code Here


        z[i] = z[i] * scale;
      }
    }

    protected Pixel computeAVGColor(SimpleImage pImg, int pX1, int pX2, int pY1, int pY2) {
      Pixel p = new Pixel();
      double red = 0.0;
      double green = 0.0;
      double blue = 0.0;
      int count = 0;
      for (int i = pX1; i < pX2; i++) {
        for (int j = pY1; j < pY2; j++) {
          p.setARGBValue(pImg.getARGBValue(i, j));
          red += p.r;
          green += p.g;
          blue += p.b;
          count++;
        }
View Full Code Here

  @Override
  protected void performPixelTransformation(WFImage pImg) {
    SimpleImage img = (SimpleImage) pImg;
    int width = pImg.getImageWidth();
    int height = pImg.getImageHeight();
    Pixel pixel = new Pixel();
    if (axis == Axis.X) {
      for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
          pixel.setARGBValue(srcImg.getARGBValue(width - j - 1, i));
          img.setRGB(j, i, pixel);
        }
      }
    }
    else if (axis == Axis.Y) {
      for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
          pixel.setARGBValue(srcImg.getARGBValue(j, height - i - 1));
          img.setRGB(j, i, pixel);
        }
      }
    }
    else if (axis == Axis.XY) {
      for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
          pixel.setARGBValue(srcImg.getARGBValue(width - j - 1, height - i - 1));
          img.setRGB(j, i, pixel);
        }
      }
    }
  }
View Full Code Here

            maxIdx = idx;
          colorMap.put(idx, Integer.parseInt(matcher.group(6)));
        }
      }
      Integer lastColor = 0;
      Pixel toolPixel = new Pixel();
      for (int i = 0; i < maxIdx; i++) {
        if (i < width) {
          Integer color = colorMap.get(i);
          if (color == null) {
            color = lastColor;
          }
          else {
            lastColor = color;
          }
          toolPixel.setARGBValue(color);
          for (int j = 0; j < height; j++) {
            // is bgr, not rgb
            res.setRGB(i, j, toolPixel.b, toolPixel.g, toolPixel.r);
          }
        }
View Full Code Here

    if (fImg == bImg)
      fImg = fImg.clone();
    SimpleImage aImg = (alphaChannelImage != null) ? alphaChannelImage : alphaChannel.getImage();
    if (aImg == bImg)
      aImg = aImg.clone();
    Pixel hPixel = new Pixel();
    Pixel bPixel = new Pixel();
    // calculate left and top edge
    int left, top;
    if (this.fgHAlign == HAlignment.CENTRE) {
      left = (bImg.getImageWidth() - fImg.getImageWidth()) / 2;
    }
    else if (this.fgHAlign == HAlignment.LEFT) {
      left = 0;
    }
    else if (this.fgHAlign == HAlignment.RIGHT) {
      left = bImg.getImageWidth() - fImg.getImageWidth();
    }
    else {
      left = this.fgLeft;
    }

    if (this.fgVAlign == VAlignment.CENTRE) {
      top = (bImg.getImageHeight() - fImg.getImageHeight()) / 2;
    }
    else if (this.fgVAlign == VAlignment.TOP) {
      top = 0;
    }
    else if (this.fgVAlign == VAlignment.BOTTOM) {
      top = bImg.getImageHeight() - fImg.getImageHeight();
    }
    else {
      top = this.fgTop;
    }
    //
    // calculate alhpa left and top edge
    int aleft, atop;
    if (this.alphaHAlign == HAlignment.CENTRE) {
      aleft = (bImg.getImageWidth() - aImg.getImageWidth()) / 2;
    }
    else if (this.alphaHAlign == HAlignment.LEFT) {
      aleft = 0;
    }
    else if (this.alphaHAlign == HAlignment.RIGHT) {
      aleft = bImg.getImageWidth() - aImg.getImageWidth();
    }
    else {
      aleft = this.alphaLeft;
    }

    if (this.alphaVAlign == VAlignment.CENTRE) {
      atop = (bImg.getImageHeight() - aImg.getImageHeight()) / 2;
    }
    else if (this.alphaVAlign == VAlignment.TOP) {
      atop = 0;
    }
    else if (this.alphaVAlign == VAlignment.BOTTOM) {
      atop = bImg.getImageHeight() - aImg.getImageHeight();
    }
    else {
      atop = this.alphaTop;
    }
    // calculate affected region
    int hsize = 0, vsize = 0;
    int bgleft = 0, bgtop = 0;
    int sleft = 0, stop = 0;
    int swidth = fImg.getImageWidth();
    int sheight = fImg.getImageHeight();
    int bgwidth = bImg.getImageWidth();
    int bgheight = bImg.getImageHeight();
    /* case 1 */
    if ((left >= 0) && (top >= 0)) {
      if ((left >= bgwidth) || (top >= bgheight))
        return;

      hsize = bgwidth - left;
      if (hsize > swidth)
        hsize = swidth;
      vsize = bgheight - top;
      if (vsize > sheight)
        vsize = sheight;
      bgtop = top;
      bgleft = left;
      sleft = 0;
      stop = 0;
    }

    /* case 2 */
    else if ((left < 0) && (top >= 0)) {
      if ((left <= (0 - swidth)) || (top >= bgheight))
        return;

      hsize = swidth + left;
      if (hsize > bgwidth)
        hsize = bgwidth;
      vsize = bgheight - top;
      if (vsize > sheight)
        vsize = sheight;
      bgtop = top;
      bgleft = 0;
      sleft = 0 - left;
      stop = 0;
    }
    /* case 3 */
    else if ((left >= 0) && (top < 0)) {
      if ((left >= bgwidth) || (top <= (0 - sheight)))
        return;
      hsize = bgwidth - left;
      if (hsize > swidth)
        hsize = swidth;
      vsize = sheight + top;
      if (vsize > bgheight)
        vsize = bgheight;
      bgtop = 0;
      bgleft = left;
      stop = 0 - top;
      sleft = 0;
    }
    /* case 4 */
    else if ((left < 0) && (top < 0)) {
      if ((left <= (0 - swidth)) || (top <= (0 - sheight)))
        return;
      hsize = swidth + left;
      if (hsize > bgwidth)
        hsize = bgwidth;
      vsize = sheight + top;
      if (vsize > bgheight)
        vsize = bgheight;
      bgtop = 0;
      bgleft = 0;
      stop = 0 - top;
      sleft = 0 - left;
    }
    // Genlock colors
    int credA = this.colorA.getRed();
    int cgreenA = this.colorA.getGreen();
    int cblueA = this.colorA.getBlue();
    int credB = this.colorB.getRed();
    int cgreenB = this.colorB.getGreen();
    int cblueB = this.colorB.getBlue();
    {
      int tc;
      if (credA > credB) {
        tc = credA;
        credA = credB;
        credB = tc;
      }
      if (cgreenA > cgreenB) {
        tc = cgreenA;
        cgreenA = cgreenB;
        cgreenB = tc;
      }
      if (cblueA > cblueB) {
        tc = cblueA;
        cblueA = cblueB;
        cblueB = tc;
      }
    }
    //
    if (this.genlock == Genlock.NONE) {
      for (int i = 0; i < vsize; i++) {
        for (int j = 0; j < hsize; j++) {
          hPixel.setARGBValue(fImg.getARGBValue(sleft + j, stop + i));
          int bgX = bgleft + j;
          int bgY = bgtop + i;
          int aX = bgX - aleft;
          int aY = bgY - atop;
          int mix = aImg.getRValueIgnoreBounds(aX, aY);
          int m1 = 255 - mix;
          int m2 = mix;
          bPixel.setARGBValue(bImg.getARGBValue(bgX, bgY));
          int r = ((int) ((int) bPixel.r * m1) + (int) ((int) hPixel.r) * m2) / (int) 255;
          int g = ((int) ((int) bPixel.g * m1) + (int) ((int) hPixel.g) * m2) / (int) 255;
          int b = ((int) ((int) bPixel.b * m1) + (int) ((int) hPixel.b) * m2) / (int) 255;
          bImg.setRGB(bgX, bgY, r, g, b);
        }
      }
    }
    else if (this.genlock == Genlock.COLOR) {
      for (int i = 0; i < vsize; i++) {
        for (int j = 0; j < hsize; j++) {
          hPixel.setARGBValue(fImg.getARGBValue(sleft + j, stop + i));
          if ((hPixel.r != credA) || (hPixel.g != cgreenA) || (hPixel.b != cblueA)) {
            int bgX = bgleft + j;
            int bgY = bgtop + i;
            int aX = bgX - aleft;
            int aY = bgY - atop;
            int mix = aImg.getRValueIgnoreBounds(aX, aY);
            int m1 = 255 - mix;
            int m2 = mix;
            bPixel.setARGBValue(bImg.getARGBValue(bgX, bgY));
            int r = ((int) ((int) bPixel.r * m1) + (int) ((int) hPixel.r) * m2) / (int) 255;
            int g = ((int) ((int) bPixel.g * m1) + (int) ((int) hPixel.g) * m2) / (int) 255;
            int b = ((int) ((int) bPixel.b * m1) + (int) ((int) hPixel.b) * m2) / (int) 255;
            bImg.setRGB(bgX, bgY, r, g, b);
          }
        }
      }
    }
    else if (this.genlock == Genlock.IN_RANGE) {
      for (int i = 0; i < vsize; i++) {
        for (int j = 0; j < hsize; j++) {
          hPixel.setARGBValue(fImg.getARGBValue(sleft + j, stop + i));
          if (((hPixel.r < credA) || (hPixel.r > credB))
              && ((hPixel.g < cgreenA) || (hPixel.g > cgreenB))
              && ((hPixel.b < cblueA) || (hPixel.b > cblueB))) {
            int bgX = bgleft + j;
            int bgY = bgtop + i;
            int aX = bgX - aleft;
            int aY = bgY - atop;
            int mix = aImg.getRValueIgnoreBounds(aX, aY);
            int m1 = 255 - mix;
            int m2 = mix;
            bPixel.setARGBValue(bImg.getARGBValue(bgX, bgY));
            int r = ((int) ((int) bPixel.r * m1) + (int) ((int) hPixel.r) * m2) / (int) 255;
            int g = ((int) ((int) bPixel.g * m1) + (int) ((int) hPixel.g) * m2) / (int) 255;
            int b = ((int) ((int) bPixel.b * m1) + (int) ((int) hPixel.b) * m2) / (int) 255;
            bImg.setRGB(bgX, bgY, r, g, b);
          }
        }
      }
    }
    else if (this.genlock == Genlock.OUT_RANGE) {
      for (int i = 0; i < vsize; i++) {
        for (int j = 0; j < hsize; j++) {
          hPixel.setARGBValue(fImg.getARGBValue(sleft + j, stop + i));
          if (((hPixel.r >= credA) && (hPixel.r <= credB))
              && ((hPixel.g >= cgreenA) && (hPixel.g <= cgreenB))
              && ((hPixel.b >= cblueA) && (hPixel.b <= cblueB))) {
            int bgX = bgleft + j;
            int bgY = bgtop + i;
            int aX = bgX - aleft;
            int aY = bgY - atop;
            int mix = aImg.getRValueIgnoreBounds(aX, aY);
            int m1 = 255 - mix;
            int m2 = mix;
            bPixel.setARGBValue(bImg.getARGBValue(bgX, bgY));
            int r = ((int) ((int) bPixel.r * m1) + (int) ((int) hPixel.r) * m2) / (int) 255;
            int g = ((int) ((int) bPixel.g * m1) + (int) ((int) hPixel.g) * m2) / (int) 255;
            int b = ((int) ((int) bPixel.b * m1) + (int) ((int) hPixel.b) * m2) / (int) 255;
            bImg.setRGB(bgX, bgY, r, g, b);
          }
View Full Code Here

    int a4x = x5 - x3;
    int a4y = y5 - y3;
    int b4x = x5 - x1;
    int b4y = y5 - y1;

    Pixel sPixel = new Pixel();
    Pixel hPixel = new Pixel();
    Pixel hLUPixel = new Pixel();
    Pixel hRUPixel = new Pixel();
    Pixel hLBPixel = new Pixel();
    Pixel hRBPixel = new Pixel();

    for (int i = 0; i < height; i++) {
      int biy = i - top;
      for (int j = 0; j < width; j++) {
        int bix = j - left;
        int z1, z2, z3, z4, z5;
        if ((bix >= 0) && (bix < bwidth) && (biy >= 0) && (biy < bheight)) {
          hPixel.setARGBValue(heightMap.getARGBValue(bix, biy));

          hLUPixel.setARGBValue(heightMap.getARGBValueIgnoreBounds(bix - 1, biy - 1));
          hRUPixel.setARGBValue(heightMap.getARGBValueIgnoreBounds(bix + 1, biy - 1));

          hLBPixel.setARGBValue(heightMap.getARGBValueIgnoreBounds(bix - 1, biy + 1));
          hRBPixel.setARGBValue(heightMap.getARGBValueIgnoreBounds(bix + 1, biy + 1));

          z5 = 0 - ((int) (hPixel.r) << SPREC) / 255;
          if (biy > 0) {
            if (bix > 0)
              z1 = 0 - ((int) (hLUPixel.r) << SPREC) / 255;
View Full Code Here

  @Override
  protected void performPixelTransformation(WFImage pImg) {
    SimpleImage img = (SimpleImage) pImg;
    int width = pImg.getImageWidth();
    int height = pImg.getImageHeight();
    Pixel pPixel = new Pixel();
    double alpha = (0.0 - this.amount) * Math.PI / 180.0;
    double cosa = Math.cos(alpha);
    double sina = Math.sin(alpha);
    double cx = this.centreX - 0.5;
    double cy = this.centreY - 0.5;
View Full Code Here

      atop = 0 - top;
      aleft = 0 - left;
    }

    img.fillBackground(0, 0, 0);
    Pixel pixel = new Pixel();
    for (int i = 0; i < vsize; i++) {
      for (int j = 0; j < hsize; j++) {
        int x = j + bgleft;
        int y = i + bgtop;
        pixel.setARGBValue(srcImg.getARGBValue(x, y));
        int a = alpha.getRValue(j + aleft, i + atop);
        pixel.r = optable[pixel.r][a];
        pixel.g = optable[pixel.g][a];
        pixel.b = optable[pixel.b][a];
        img.setRGB(x, y, pixel);
View Full Code Here

            img.setARGB(j, i, srcImg.getARGBValue(xLumMax, yLumMax));
          }
        }
        break;
      case NEON:
        Pixel srcPixel = new Pixel();
        Pixel currPixel = new Pixel();
        for (int i = 0; i < height; i++) {
          for (int j = 0; j < width; j++) {
            int lumMax = srcGreyImg.getRValue(j, i);
            int lum0 = lumMax;
            int xLumMax = j;
            int yLumMax = i;
            for (int s = 0; s < shape.length; s++) {
              int x = j + shape[s][0];
              int y = i + shape[s][1];
              if ((x >= 0) && (x < width) && (y >= 0) && (y < height)) {
                int lum = srcGreyImg.getRValue(x, y);
                if (lum > lumMax) {
                  lumMax = lum;
                  xLumMax = x;
                  yLumMax = y;
                }
              }
            }
            int m1 = 30;
            int m2 = 100 - m1;
            srcPixel.setARGBValue(srcImg.getARGBValue(xLumMax, yLumMax));
            currPixel.setARGBValue(srcImg.getARGBValue(j, i));
            currPixel.r = (srcPixel.r * m1 + currPixel.r * m2) / 100;
            currPixel.g = (srcPixel.g * m1 + currPixel.g * m2) / 100;
            currPixel.b = (srcPixel.b * m1 + currPixel.b * m2) / 100;
            if (Math.abs(lum0 - lumMax) > 50)
              img.setRGB(j, i, 0, 128, 0);
View Full Code Here

  protected void performPixelTransformation(WFImage pImg) {
    SimpleImage img = (SimpleImage) pImg;
    SimpleImage fImg = (foregroundImage != null) ? foregroundImage : foreground.getImage();
    int width = pImg.getImageWidth();
    int height = pImg.getImageHeight();
    Pixel srcPixel = new Pixel();
    Pixel dstPixel = new Pixel();
    if (mode == Mode.ADD) {
      for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
          srcPixel.setARGBValue(fImg.getARGBValueIgnoreBounds(j, i));
          dstPixel.setARGBValue(img.getARGBValue(j, i));
          dstPixel.r += srcPixel.r;
          if (dstPixel.r > 255)
            dstPixel.r = 255;
          dstPixel.g += srcPixel.g;
          if (dstPixel.g > 255)
            dstPixel.g = 255;
          dstPixel.b += srcPixel.b;
          if (dstPixel.b > 255)
            dstPixel.b = 255;
          img.setRGB(j, i, dstPixel);
        }
      }
    }
    else if (mode == Mode.SUBTRACT) {
      for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
          srcPixel.setARGBValue(fImg.getARGBValueIgnoreBounds(j, i));
          dstPixel.setARGBValue(img.getARGBValue(j, i));
          dstPixel.r -= srcPixel.r;
          if (dstPixel.r < 0)
            dstPixel.r = 0;
          dstPixel.g -= srcPixel.g;
          if (dstPixel.g < 0)
            dstPixel.g = 0;
          dstPixel.b -= srcPixel.b;
          if (dstPixel.b < 0)
            dstPixel.b = 0;
          img.setRGB(j, i, dstPixel);
        }
      }
    }
    else if (mode == Mode.EXPOSURE) {
      for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
          srcPixel.setARGBValue(fImg.getARGBValueIgnoreBounds(j, i));
          dstPixel.setARGBValue(img.getARGBValue(j, i));
          dstPixel.r = expose(dstPixel.r + 2 * srcPixel.r);
          dstPixel.g = expose(dstPixel.g + 2 * srcPixel.g);
          dstPixel.b = expose(dstPixel.b + 2 * srcPixel.b);
          img.setRGB(j, i, dstPixel);
        }
View Full Code Here

TOP

Related Classes of org.jwildfire.image.Pixel

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.