Java Code Examples for java.awt.image.LookupOp

The following are top voted examples for showing how to use java.awt.image.LookupOp. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: jdk8u-jdk   File: IntImageReverseTest.java   View source code 6 votes vote down vote up
public static void main(String[] args) {
    LookupTable tbl = createReverseTable();
    LookupOp op = new LookupOp(tbl, null);

    for (ImageType t : ImageType.values()) {
        System.out.print(t);

        BufferedImage src = createSourceImage(t);

        BufferedImage dst = op.filter(src, null);

        int rgb = dst.getRGB(0, 0);

        System.out.printf(" Result: 0x%X ", rgb);

        if (rgb != argbReverse) {
            throw new RuntimeException("Test failed.");
        }
        System.out.println("Passed.");
    }
}
 
Example 2
Project: openjdk-jdk10   File: RasterOpNullDestinationRasterTest.java   View source code 6 votes vote down vote up
public static void main(String[] args) {

        byte[][] data = new byte[1][10];
        ByteLookupTable lut = new ByteLookupTable(0, data);
        RasterOp op = new LookupOp(lut, null);

        int[] bandOffsets = {0};
        Point location = new Point(0, 0);
        DataBuffer db = new DataBufferByte(10 * 10);
        SampleModel sm = new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE,
                                                         10, 10, 1, 10,
                                                         bandOffsets);

        Raster src = Raster.createRaster(sm, db, location);

        op.filter(src, null); // this used to result in NullPointerException
    }
 
Example 3
Project: openjdk-jdk10   File: IntImageReverseTest.java   View source code 6 votes vote down vote up
public static void main(String[] args) {
    LookupTable tbl = createReverseTable();
    LookupOp op = new LookupOp(tbl, null);

    for (ImageType t : ImageType.values()) {
        System.out.print(t);

        BufferedImage src = createSourceImage(t);

        BufferedImage dst = op.filter(src, null);

        int rgb = dst.getRGB(0, 0);

        System.out.printf(" Result: 0x%X ", rgb);

        if (rgb != argbReverse) {
            throw new RuntimeException("Test failed.");
        }
        System.out.println("Passed.");
    }
}
 
Example 4
Project: geomapapp   File: ImageComponent.java   View source code 6 votes vote down vote up
public void apply() {
	if( balance==null ) return;
	ByteLookupTable lookup = balance.getLookup();
	if(lookup==null) return;
	
	int ok = (getTopLevelAncestor() instanceof JFrame )
		? JOptionPane.showConfirmDialog(
			(JFrame)getTopLevelAncestor(),
			"Apply Color Mods?",
			"Modify Image Color",
			JOptionPane.YES_NO_OPTION)
		: JOptionPane.showConfirmDialog(
			(JOptionPane)getTopLevelAncestor(),
			"Apply Color Mods?",
			"Modify Image Color",
			JOptionPane.YES_NO_OPTION);
	if( ok== JOptionPane.NO_OPTION) return;
	BufferedImage im = new BufferedImage( width, height, 
		image.TYPE_INT_RGB);
	Graphics2D g = im.createGraphics();
	g.drawImage( image, new LookupOp( lookup, null ), 0, 0);
	image = im;
	balance.reset();
}
 
Example 5
Project: openjdk9   File: IntImageReverseTest.java   View source code 6 votes vote down vote up
public static void main(String[] args) {
    LookupTable tbl = createReverseTable();
    LookupOp op = new LookupOp(tbl, null);

    for (ImageType t : ImageType.values()) {
        System.out.print(t);

        BufferedImage src = createSourceImage(t);

        BufferedImage dst = op.filter(src, null);

        int rgb = dst.getRGB(0, 0);

        System.out.printf(" Result: 0x%X ", rgb);

        if (rgb != argbReverse) {
            throw new RuntimeException("Test failed.");
        }
        System.out.println("Passed.");
    }
}
 
Example 6
Project: Push2Display   File: SVGBufferedImageOp.java   View source code 6 votes vote down vote up
/**
 * @param op BufferedImageOp to be converted to SVG
 * @param filterRect Rectangle, in device space, that defines the area
 *        to which filtering applies. May be null, meaning that the
 *        area is undefined.
 * @return an SVGFilterDescriptor representing the SVG filter
 *         equivalent of the input BufferedImageOp
 */
public SVGFilterDescriptor toSVG(BufferedImageOp op,
                                 Rectangle filterRect){
    SVGFilterDescriptor filterDesc =
        svgCustomBufferedImageOp.toSVG(op, filterRect);

    if(filterDesc == null){
        if(op instanceof LookupOp)
            filterDesc = svgLookupOp.toSVG(op, filterRect);
        else if(op instanceof RescaleOp)
            filterDesc = svgRescaleOp.toSVG(op, filterRect);
        else if(op instanceof ConvolveOp)
            filterDesc = svgConvolveOp.toSVG(op, filterRect);
    }

    return filterDesc;
}
 
Example 7
Project: Push2Display   File: ComponentTransferRed.java   View source code 6 votes vote down vote up
/**
 * The constructor will instantiate a LookupOp instance using
 * a LookupOp, which is built using the four LUT
 * data obtained by the TransferFunction objects
 * funcs[0] : Alpha component transfer function
 * funcs[1] : Red component transfer function
 * funcs[2] : Green component transfer function
 * funcs[3] : Blue component transfer function
 */
public ComponentTransferRed(CachableRed src,
                            TransferFunction [] funcs,
                            RenderingHints hints) {
    super(src, src.getBounds(),
          GraphicsUtil.coerceColorModel(src.getColorModel(), false),
          src.getSampleModel(),
          null);

    byte [][] tableData = {funcs[1].getLookupTable(),
                           funcs[2].getLookupTable(),
                           funcs[3].getLookupTable(),
                           funcs[0].getLookupTable()};

    // Note that we create an anonymous subclass here.
    // For what ever reason this makes the Op work correctly.
    // If you remove this, it seems to get the color channels messed
    // up.  The downside is that I suspect that this means we are
    // falling into a more general, and hence slower case, but
    // at least it works....
    operation  =  new LookupOp(new ByteLookupTable(0, tableData), hints)
        { };
}
 
Example 8
Project: jdk8u_jdk   File: IntImageReverseTest.java   View source code 6 votes vote down vote up
public static void main(String[] args) {
    LookupTable tbl = createReverseTable();
    LookupOp op = new LookupOp(tbl, null);

    for (ImageType t : ImageType.values()) {
        System.out.print(t);

        BufferedImage src = createSourceImage(t);

        BufferedImage dst = op.filter(src, null);

        int rgb = dst.getRGB(0, 0);

        System.out.printf(" Result: 0x%X ", rgb);

        if (rgb != argbReverse) {
            throw new RuntimeException("Test failed.");
        }
        System.out.println("Passed.");
    }
}
 
Example 9
Project: lookaside_java-1.8.0-openjdk   File: IntImageReverseTest.java   View source code 6 votes vote down vote up
public static void main(String[] args) {
    LookupTable tbl = createReverseTable();
    LookupOp op = new LookupOp(tbl, null);

    for (ImageType t : ImageType.values()) {
        System.out.print(t);

        BufferedImage src = createSourceImage(t);

        BufferedImage dst = op.filter(src, null);

        int rgb = dst.getRGB(0, 0);

        System.out.printf(" Result: 0x%X ", rgb);

        if (rgb != argbReverse) {
            throw new RuntimeException("Test failed.");
        }
        System.out.println("Passed.");
    }
}
 
Example 10
Project: Push2Display   File: SVGBufferedImageOp.java   View source code 6 votes vote down vote up
/**
 * @param op BufferedImageOp to be converted to SVG
 * @param filterRect Rectangle, in device space, that defines the area
 *        to which filtering applies. May be null, meaning that the
 *        area is undefined.
 * @return an SVGFilterDescriptor representing the SVG filter
 *         equivalent of the input BufferedImageOp
 */
public SVGFilterDescriptor toSVG(BufferedImageOp op,
                                 Rectangle filterRect){
    SVGFilterDescriptor filterDesc =
        svgCustomBufferedImageOp.toSVG(op, filterRect);

    if(filterDesc == null){
        if(op instanceof LookupOp)
            filterDesc = svgLookupOp.toSVG(op, filterRect);
        else if(op instanceof RescaleOp)
            filterDesc = svgRescaleOp.toSVG(op, filterRect);
        else if(op instanceof ConvolveOp)
            filterDesc = svgConvolveOp.toSVG(op, filterRect);
    }

    return filterDesc;
}
 
Example 11
Project: Push2Display   File: ComponentTransferRed.java   View source code 6 votes vote down vote up
/**
 * The constructor will instantiate a LookupOp instance using
 * a LookupOp, which is built using the four LUT
 * data obtained by the TransferFunction objects
 * funcs[0] : Alpha component transfer function
 * funcs[1] : Red component transfer function
 * funcs[2] : Green component transfer function
 * funcs[3] : Blue component transfer function
 */
public ComponentTransferRed(CachableRed src,
                            TransferFunction [] funcs,
                            RenderingHints hints) {
    super(src, src.getBounds(),
          GraphicsUtil.coerceColorModel(src.getColorModel(), false),
          src.getSampleModel(),
          null);

    byte [][] tableData = {funcs[1].getLookupTable(),
                           funcs[2].getLookupTable(),
                           funcs[3].getLookupTable(),
                           funcs[0].getLookupTable()};

    // Note that we create an anonymous subclass here.
    // For what ever reason this makes the Op work correctly.
    // If you remove this, it seems to get the color channels messed
    // up.  The downside is that I suspect that this means we are
    // falling into a more general, and hence slower case, but
    // at least it works....
    operation  =  new LookupOp(new ByteLookupTable(0, tableData), hints)
        { };
}
 
Example 12
Project: SmartTokens   File: GUIUtils.java   View source code 6 votes vote down vote up
/**
 * For testing lookup tables
 */
public static Image toInverseVideo(Image source) {
	//
	BufferedImage src = new BufferedImage(source.getWidth(null), source
			.getHeight(null), BufferedImage.TYPE_INT_ARGB);
	Graphics g = src.getGraphics();
	g.drawImage(source, 0, 0, null);
	//
	short[][] lookup = new short[4][256];
	for (int c = 0; c < 4; c++) {
		for (short b = 0; b < 256; b++) {
			if (c == 3)
				lookup[c][b] = b;
			else
				lookup[c][b] = (short)(255 - b);
		}
	}
	LookupTable table = new ShortLookupTable(0, lookup);
	LookupOp op = new LookupOp (table, null);
	return op.filter(src, null);
}
 
Example 13
Project: infobip-open-jdk-8   File: IntImageReverseTest.java   View source code 6 votes vote down vote up
public static void main(String[] args) {
    LookupTable tbl = createReverseTable();
    LookupOp op = new LookupOp(tbl, null);

    for (ImageType t : ImageType.values()) {
        System.out.print(t);

        BufferedImage src = createSourceImage(t);

        BufferedImage dst = op.filter(src, null);

        int rgb = dst.getRGB(0, 0);

        System.out.printf(" Result: 0x%X ", rgb);

        if (rgb != argbReverse) {
            throw new RuntimeException("Test failed.");
        }
        System.out.println("Passed.");
    }
}
 
Example 14
Project: jdk8u-dev-jdk   File: IntImageReverseTest.java   View source code 6 votes vote down vote up
public static void main(String[] args) {
    LookupTable tbl = createReverseTable();
    LookupOp op = new LookupOp(tbl, null);

    for (ImageType t : ImageType.values()) {
        System.out.print(t);

        BufferedImage src = createSourceImage(t);

        BufferedImage dst = op.filter(src, null);

        int rgb = dst.getRGB(0, 0);

        System.out.printf(" Result: 0x%X ", rgb);

        if (rgb != argbReverse) {
            throw new RuntimeException("Test failed.");
        }
        System.out.println("Passed.");
    }
}
 
Example 15
Project: feathers-sdk   File: SVGBufferedImageOp.java   View source code 6 votes vote down vote up
/**
 * @param op BufferedImageOp to be converted to SVG
 * @param filterRect Rectangle, in device space, that defines the area
 *        to which filtering applies. May be null, meaning that the
 *        area is undefined.
 * @return an SVGFilterDescriptor representing the SVG filter
 *         equivalent of the input BufferedImageOp
 */
public SVGFilterDescriptor toSVG(BufferedImageOp op,
                                 Rectangle filterRect){
    SVGFilterDescriptor filterDesc =
        svgCustomBufferedImageOp.toSVG(op, filterRect);

    if(filterDesc == null){
        if(op instanceof LookupOp)
            filterDesc = svgLookupOp.toSVG(op, filterRect);
        else if(op instanceof RescaleOp)
            filterDesc = svgRescaleOp.toSVG(op, filterRect);
        else if(op instanceof ConvolveOp)
            filterDesc = svgConvolveOp.toSVG(op, filterRect);
    }

    return filterDesc;
}
 
Example 16
Project: feathers-sdk   File: ComponentTransferRed.java   View source code 6 votes vote down vote up
/**
 * The constructor will instantiate a LookupOp instance using
 * a LookupOp, which is built using the four LUT
 * data obtained by the TransferFunction objects
 * funcs[0] : Alpha component transfer function
 * funcs[1] : Red component transfer function
 * funcs[2] : Green component transfer function
 * funcs[3] : Blue component transfer function
 */
public ComponentTransferRed(CachableRed src,
                            TransferFunction [] funcs,
                            RenderingHints hints) {
    super(src, src.getBounds(),
          GraphicsUtil.coerceColorModel(src.getColorModel(), false),
          src.getSampleModel(),
          null);

    byte [][] tableData = {funcs[1].getLookupTable(),
                           funcs[2].getLookupTable(),
                           funcs[3].getLookupTable(),
                           funcs[0].getLookupTable()};

    // Note that we create an anonymous subclass here.
    // For what ever reason this makes the Op work correctly.
    // If you remove this, it seems to get the color channels messed
    // up.  The downside is that I suspect that this means we are
    // falling into a more general, and hence slower case, but
    // at least it works....
    operation  =  new LookupOp(new ByteLookupTable(0, tableData), hints)
        { };
}
 
Example 17
Project: OLD-OpenJDK8   File: IntImageReverseTest.java   View source code 6 votes vote down vote up
public static void main(String[] args) {
    LookupTable tbl = createReverseTable();
    LookupOp op = new LookupOp(tbl, null);

    for (ImageType t : ImageType.values()) {
        System.out.print(t);

        BufferedImage src = createSourceImage(t);

        BufferedImage dst = op.filter(src, null);

        int rgb = dst.getRGB(0, 0);

        System.out.printf(" Result: 0x%X ", rgb);

        if (rgb != argbReverse) {
            throw new RuntimeException("Test failed.");
        }
        System.out.println("Passed.");
    }
}
 
Example 18
Project: Sistemas-Multimedia   File: VentanaPrincipal.java   View source code 6 votes vote down vote up
private void botonContrasteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonContrasteActionPerformed

        try {
            VentanaInterna vi = (VentanaInterna) escritorio.getSelectedFrame();
            if (vi != null) {
                BufferedImage imgActual = convertImageType(vi.getLienzo().getImageActual(), BufferedImage.TYPE_INT_RGB);
                LookupTable ltp = LookupTableProducer.createLookupTable(LookupTableProducer.TYPE_SFUNCION);
                LookupOp lop = new LookupOp(ltp, null);
                BufferedImage imgdest = lop.filter(imgActual, null);

                if (imgdest != null) {
                    vi.getLienzo().setImageOriginal(imgdest);
                    vi.getLienzo().repaint();
                }
            }
        } catch (Exception e) {
            System.err.println("Error en el contraste");
        }
    }
 
Example 19
Project: Sistemas-Multimedia   File: VentanaPrincipal.java   View source code 6 votes vote down vote up
private void botonIluminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonIluminarActionPerformed
    try {
        VentanaInterna vi = (VentanaInterna) escritorio.getSelectedFrame();
        if (vi != null) {
            BufferedImage imgActual = convertImageType(vi.getLienzo().getImageActual(), BufferedImage.TYPE_INT_RGB);
            LookupTable ltp = LookupTableProducer.createLookupTable(LookupTableProducer.TYPE_LOGARITHM);
            LookupOp lop = new LookupOp(ltp, null);
            BufferedImage imgdest = lop.filter(imgActual, null);

            if (imgdest != null) {
                vi.getLienzo().setImageOriginal(imgdest);
                vi.getLienzo().repaint();
            }
        }
    } catch (Exception e) {
        System.err.println("Error al iluminar");
    }
}
 
Example 20
Project: Sistemas-Multimedia   File: VentanaPrincipal.java   View source code 6 votes vote down vote up
private void botonOscurecerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonOscurecerActionPerformed
    try {
        VentanaInterna vi = (VentanaInterna) escritorio.getSelectedFrame();
        if (vi != null) {
            BufferedImage imgActual = convertImageType(vi.getLienzo().getImageActual(), BufferedImage.TYPE_INT_RGB);
            LookupTable ltp = LookupTableProducer.createLookupTable(LookupTableProducer.TYPE_POWER);
            LookupOp lop = new LookupOp(ltp, null);
            BufferedImage imgdest = lop.filter(imgActual, null);
            if (imgdest != null) {
                vi.getLienzo().setImageOriginal(imgdest);
                vi.getLienzo().repaint();
            }
        }
    } catch (Exception e) {
        System.err.println("Error al oscurecer");
    }
}
 
Example 21
Project: Sistemas-Multimedia   File: VentanaPrincipal.java   View source code 6 votes vote down vote up
private void botonContrasteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonContrasteActionPerformed

        try {
            VentanaInterna vi = (VentanaInterna) escritorio.getSelectedFrame();
            if (vi != null) {
                BufferedImage imgActual = convertImageType(vi.getLienzo().getImageActual(), BufferedImage.TYPE_INT_RGB);
                LookupTable ltp = LookupTableProducer.createLookupTable(LookupTableProducer.TYPE_SFUNCION);
                LookupOp lop = new LookupOp(ltp, null);
                BufferedImage imgdest = lop.filter(imgActual, null);

                if (imgdest != null) {
                    vi.getLienzo().setImageOriginal(imgdest);
                    vi.getLienzo().repaint();
                }
            }
        } catch (Exception e) {
            System.err.println("Error en el contraste");
        }
    }
 
Example 22
Project: Sistemas-Multimedia   File: VentanaPrincipal.java   View source code 6 votes vote down vote up
private void botonIluminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonIluminarActionPerformed
    try {
        VentanaInterna vi = (VentanaInterna) escritorio.getSelectedFrame();
        if (vi != null) {
            BufferedImage imgActual = convertImageType(vi.getLienzo().getImageActual(), BufferedImage.TYPE_INT_RGB);
            LookupTable ltp = LookupTableProducer.createLookupTable(LookupTableProducer.TYPE_LOGARITHM);
            LookupOp lop = new LookupOp(ltp, null);
            BufferedImage imgdest = lop.filter(imgActual, null);

            if (imgdest != null) {
                vi.getLienzo().setImageOriginal(imgdest);
                vi.getLienzo().repaint();
            }
        }
    } catch (Exception e) {
        System.err.println("Error al iluminar");
    }
}
 
Example 23
Project: Sistemas-Multimedia   File: VentanaPrincipal.java   View source code 6 votes vote down vote up
private void botonOscurecerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonOscurecerActionPerformed
    try {
        VentanaInterna vi = (VentanaInterna) escritorio.getSelectedFrame();
        if (vi != null) {
            BufferedImage imgActual = convertImageType(vi.getLienzo().getImageActual(), BufferedImage.TYPE_INT_RGB);
            LookupTable ltp = LookupTableProducer.createLookupTable(LookupTableProducer.TYPE_POWER);
            LookupOp lop = new LookupOp(ltp, null);
            BufferedImage imgdest = lop.filter(imgActual, null);
            if (imgdest != null) {
                vi.getLienzo().setImageOriginal(imgdest);
                vi.getLienzo().repaint();
            }
        }
    } catch (Exception e) {
        System.err.println("Error al oscurecer");
    }
}
 
Example 24
Project: Sistemas-Multimedia   File: VentanaPrincipal.java   View source code 6 votes vote down vote up
private void botonContrasteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonContrasteActionPerformed

        try {
            VentanaInternaImagen vi = (VentanaInternaImagen) selectInternalWindows();
            if (vi != null) {
                BufferedImage imgActual = convertImageType(vi.getLienzo().getImageActual(), BufferedImage.TYPE_INT_RGB);
                LookupTable ltp = LookupTableProducer.createLookupTable(LookupTableProducer.TYPE_SFUNCION);
                LookupOp lop = new LookupOp(ltp, null);
                BufferedImage imgdest = lop.filter(imgActual, null);

                if (imgdest != null) {
                    vi.getLienzo().setImageOriginal(imgdest);
                    vi.getLienzo().repaint();
                }
            }
        } catch (Exception e) {
            System.err.println("Error en el contraste");
        }
    }
 
Example 25
Project: Sistemas-Multimedia   File: VentanaPrincipal.java   View source code 6 votes vote down vote up
private void botonIluminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonIluminarActionPerformed
    try {
        VentanaInternaImagen vi = (VentanaInternaImagen) selectInternalWindows();
        if (vi != null) {
            BufferedImage imgActual = convertImageType(vi.getLienzo().getImageActual(), BufferedImage.TYPE_INT_RGB);
            LookupTable ltp = LookupTableProducer.createLookupTable(LookupTableProducer.TYPE_LOGARITHM);
            LookupOp lop = new LookupOp(ltp, null);
            BufferedImage imgdest = lop.filter(imgActual, null);

            if (imgdest != null) {
                vi.getLienzo().setImageOriginal(imgdest);
                vi.getLienzo().repaint();
            }
        }
    } catch (Exception e) {
        System.err.println("Error al iluminar");
    }
}
 
Example 26
Project: Sistemas-Multimedia   File: VentanaPrincipal.java   View source code 6 votes vote down vote up
private void botonOscurecerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonOscurecerActionPerformed
    try {
        VentanaInternaImagen vi = (VentanaInternaImagen) selectInternalWindows();
        if (vi != null) {
            BufferedImage imgActual = convertImageType(vi.getLienzo().getImageActual(), BufferedImage.TYPE_INT_RGB);
            LookupTable ltp = LookupTableProducer.createLookupTable(LookupTableProducer.TYPE_POWER);
            LookupOp lop = new LookupOp(ltp, null);
            BufferedImage imgdest = lop.filter(imgActual, null);
            if (imgdest != null) {
                vi.getLienzo().setImageOriginal(imgdest);
                vi.getLienzo().repaint();
            }
        }
    } catch (Exception e) {
        System.err.println("Error al oscurecer");
    }
}
 
Example 27
Project: Sistemas-Multimedia   File: VentanaPrincipal.java   View source code 6 votes vote down vote up
private void negativeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_negativeActionPerformed
    try {
        VentanaInternaImagen vi = (VentanaInternaImagen) selectInternalWindows();
        if (vi != null) {
            BufferedImage imgActual = convertImageType(vi.getLienzo().getImageActual(), BufferedImage.TYPE_INT_RGB);
            LookupTable ltp = LookupTableProducer.createLookupTable(LookupTableProducer.TYPE_NEGATIVE);
            LookupOp lop = new LookupOp(ltp, null);
            BufferedImage imgdest = lop.filter(imgActual, null);

            if (imgdest != null) {
                vi.getLienzo().setImageOriginal(imgdest);
                vi.getLienzo().repaint();
            }
        }
    } catch (Exception e) {
        System.err.println("Error en el contraste");
    }
}
 
Example 28
Project: Sistemas-Multimedia   File: VentanaPrincipal.java   View source code 6 votes vote down vote up
private void botonContrasteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonContrasteActionPerformed

      try {
          VentanaInterna vi = (VentanaInterna) escritorio.getSelectedFrame();
          if (vi != null) {
              BufferedImage imgActual = convertImageType(vi.getLienzo().getImageActual(), BufferedImage.TYPE_INT_RGB);
              LookupTable ltp = LookupTableProducer.createLookupTable(LookupTableProducer.TYPE_SFUNCION);
              LookupOp lop = new LookupOp(ltp, null);
              BufferedImage imgdest = lop.filter(imgActual, null);
              
              if (imgdest != null){
                  vi.getLienzo().setImageOriginal(imgdest);
                  vi.getLienzo().repaint();
              }
          }
      } catch (Exception e) {
          System.err.println("Error en el contraste");
      }
  }
 
Example 29
Project: Sistemas-Multimedia   File: VentanaPrincipal.java   View source code 6 votes vote down vote up
private void botonIluminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonIluminarActionPerformed
    try {
        VentanaInterna vi = (VentanaInterna) escritorio.getSelectedFrame();
        if (vi != null) {
            BufferedImage imgActual = convertImageType(vi.getLienzo().getImageActual(), BufferedImage.TYPE_INT_RGB);
            LookupTable ltp = LookupTableProducer.createLookupTable(LookupTableProducer.TYPE_LOGARITHM);
            LookupOp lop = new LookupOp(ltp, null);
            BufferedImage imgdest = lop.filter(imgActual, null);
            
            if (imgdest != null){
                vi.getLienzo().setImageOriginal(imgdest);
                vi.getLienzo().repaint();
            }
        }
    } catch (Exception e) {
        System.err.println("Error al iluminar");
    }
}
 
Example 30
Project: Sistemas-Multimedia   File: VentanaPrincipal.java   View source code 6 votes vote down vote up
private void botonOscurecerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonOscurecerActionPerformed
    try {
        VentanaInterna vi = (VentanaInterna) escritorio.getSelectedFrame();
        if (vi != null) {
            BufferedImage imgActual = convertImageType(vi.getLienzo().getImageActual(), BufferedImage.TYPE_INT_RGB);
            LookupTable ltp = LookupTableProducer.createLookupTable(LookupTableProducer.TYPE_POWER);
            LookupOp lop = new LookupOp(ltp, null);
            BufferedImage imgdest = lop.filter(imgActual, null);
            if (imgdest != null){
                vi.getLienzo().setImageOriginal(imgdest);
                vi.getLienzo().repaint();
            }
        }
    } catch (Exception e) {
        System.err.println("Error al oscurecer");
    }
}
 
Example 31
Project: geneaquilt   File: GUIUtils.java   View source code 6 votes vote down vote up
/**
 * For testing lookup tables
 */
public static Image toInverseVideo(Image source) {
	//
	BufferedImage src = new BufferedImage(source.getWidth(null), source
			.getHeight(null), BufferedImage.TYPE_INT_ARGB);
	Graphics g = src.getGraphics();
	g.drawImage(source, 0, 0, null);
	//
	short[][] lookup = new short[4][256];
	for (int c = 0; c < 4; c++) {
		for (short b = 0; b < 256; b++) {
			if (c == 3)
				lookup[c][b] = b;
			else
				lookup[c][b] = (short)(255 - b);
		}
	}
	LookupTable table = new ShortLookupTable(0, lookup);
	LookupOp op = new LookupOp (table, null);
	return op.filter(src, null);
}
 
Example 32
Project: OpenJSharp   File: BufferedBufImgOps.java   View source code 5 votes vote down vote up
public static void enableBufImgOp(RenderQueue rq, SurfaceData srcData,
                                  BufferedImage srcImg,
                                  BufferedImageOp biop)
{
    if (biop instanceof ConvolveOp) {
        enableConvolveOp(rq, srcData, (ConvolveOp)biop);
    } else if (biop instanceof RescaleOp) {
        enableRescaleOp(rq, srcData, srcImg, (RescaleOp)biop);
    } else if (biop instanceof LookupOp) {
        enableLookupOp(rq, srcData, srcImg, (LookupOp)biop);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example 33
Project: OpenJSharp   File: BufferedBufImgOps.java   View source code 5 votes vote down vote up
public static void disableBufImgOp(RenderQueue rq, BufferedImageOp biop) {
    if (biop instanceof ConvolveOp) {
        disableConvolveOp(rq);
    } else if (biop instanceof RescaleOp) {
        disableRescaleOp(rq);
    } else if (biop instanceof LookupOp) {
        disableLookupOp(rq);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example 34
Project: jdk8u-jdk   File: BufferedBufImgOps.java   View source code 5 votes vote down vote up
public static void enableBufImgOp(RenderQueue rq, SurfaceData srcData,
                                  BufferedImage srcImg,
                                  BufferedImageOp biop)
{
    if (biop instanceof ConvolveOp) {
        enableConvolveOp(rq, srcData, (ConvolveOp)biop);
    } else if (biop instanceof RescaleOp) {
        enableRescaleOp(rq, srcData, srcImg, (RescaleOp)biop);
    } else if (biop instanceof LookupOp) {
        enableLookupOp(rq, srcData, srcImg, (LookupOp)biop);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example 35
Project: jdk8u-jdk   File: BufferedBufImgOps.java   View source code 5 votes vote down vote up
public static void disableBufImgOp(RenderQueue rq, BufferedImageOp biop) {
    if (biop instanceof ConvolveOp) {
        disableConvolveOp(rq);
    } else if (biop instanceof RescaleOp) {
        disableRescaleOp(rq);
    } else if (biop instanceof LookupOp) {
        disableLookupOp(rq);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example 36
Project: jdk8u-jdk   File: MlibOpsTest.java   View source code 5 votes vote down vote up
private static BufferedImageOp getLookupOp() {
    byte[] inv = new byte[256];
    for (int i = 0; i < 256; i++) {
        inv[i] = (byte)(255 - i);
    }
    ByteLookupTable table = new ByteLookupTable(0, inv);
    return new LookupOp(table, null);
}
 
Example 37
Project: jdk8u-jdk   File: SingleArrayTest.java   View source code 5 votes vote down vote up
public SingleArrayTest() {

        byte[] array = new byte[256];
        for (int i = 0; i < 256; i++) {
            array[i] = (byte)i;
        }
        ByteLookupTable table = new ByteLookupTable(0, array);

        op = new LookupOp(table, null);
    }
 
Example 38
Project: openjdk-jdk10   File: BufferedBufImgOps.java   View source code 5 votes vote down vote up
public static void enableBufImgOp(RenderQueue rq, SurfaceData srcData,
                                  BufferedImage srcImg,
                                  BufferedImageOp biop)
{
    if (biop instanceof ConvolveOp) {
        enableConvolveOp(rq, srcData, (ConvolveOp)biop);
    } else if (biop instanceof RescaleOp) {
        enableRescaleOp(rq, srcData, srcImg, (RescaleOp)biop);
    } else if (biop instanceof LookupOp) {
        enableLookupOp(rq, srcData, srcImg, (LookupOp)biop);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example 39
Project: openjdk-jdk10   File: BufferedBufImgOps.java   View source code 5 votes vote down vote up
public static void disableBufImgOp(RenderQueue rq, BufferedImageOp biop) {
    if (biop instanceof ConvolveOp) {
        disableConvolveOp(rq);
    } else if (biop instanceof RescaleOp) {
        disableRescaleOp(rq);
    } else if (biop instanceof LookupOp) {
        disableLookupOp(rq);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example 40
Project: openjdk-jdk10   File: MlibOpsTest.java   View source code 5 votes vote down vote up
private static BufferedImageOp getLookupOp() {
    byte[] inv = new byte[256];
    for (int i = 0; i < 256; i++) {
        inv[i] = (byte)(255 - i);
    }
    ByteLookupTable table = new ByteLookupTable(0, inv);
    return new LookupOp(table, null);
}