Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.untref.gui; import com.untref.utiles.Graficador; import com.untref.bordes.DetectorDeBordes; import com.untref.bordes.DetectorDeBordesCanny; import com.untref.bordes.DetectorDeBordesDireccionales; import com.untref.bordes.DetectorDeBordesLeclerc; import com.untref.bordes.DetectorDeBordesLorentz; import com.untref.bordes.DetectorDeHarris; import com.untref.bordes.DetectorSusan; import com.untref.bordes.HoughCirculos; import com.untref.bordes.InterfaceDetectorDeBordes; import com.untref.bordes.TranformadaDeHoughRectas; import com.untref.enums.Canal; import com.untref.enums.FormatoDeImagen; import com.untref.modelo.Imagen; import com.untref.sift.Sift; import com.untref.utiles.Difuminador; import com.untref.utiles.ExtensionFileFilter; import com.untref.utiles.FiltroGaussiano; import com.untref.utiles.Filtros; import com.untref.utiles.GeneradorDeRuido; import com.untref.utiles.Histograma2; import com.untref.utiles.LayoutFileFilter; import com.untref.utiles.Operaciones; import com.untref.utiles.ProcImagenes; import com.untref.utiles.Umbralizador; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Point; import java.awt.Rectangle; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.DataBufferByte; import java.awt.image.WritableRaster; import java.io.File; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JDesktopPane; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.filechooser.FileNameExtensionFilter; import org.opencv.core.Core; import org.opencv.core.CvType; import org.opencv.core.Mat; import org.opencv.core.Scalar; import org.opencv.core.Size; import org.opencv.highgui.Highgui; import org.opencv.imgproc.Imgproc; /** * * @author karlagutz */ public class Editar extends javax.swing.JInternalFrame { /** * Creates new form Editar */ private ProcImagenes p; private Operaciones Op = new Operaciones(); private Filtros f = new Filtros(); private Rectangle captureRect = new Rectangle(); private Point start = new Point(); private Point end; private Point startClick; private BufferedImage screen; private BufferedImage screenCopy; private Histograma2 objHistograma; private VentanaHistograma objVentanaHistograma; private GeneradorDeRuido gdr; public Editar(ProcImagenes pro) { initComponents(); this.p = pro; this.gdr = new GeneradorDeRuido(); objVentanaHistograma = new VentanaHistograma(); seleccionarRectangulo(p.getImageActual()); } public BufferedImage getScreen() { return this.screen; } public void seleccionarRectangulo(BufferedImage screen) { this.screen = screen; screenCopy = new BufferedImage(screen.getWidth(), screen.getHeight(), screen.getType()); screenLabel.setIcon(new ImageIcon(screenCopy)); repaint(screen, screenCopy); screenLabel.repaint(); } public void repaint(BufferedImage orig, BufferedImage copy) { Graphics2D g = copy.createGraphics(); g.drawImage(orig, 0, 0, null); if (captureRect != null) { g.setColor(Color.RED); g.draw(captureRect); g.setColor(new Color(255, 255, 255, 150)); g.fill(captureRect); } g.dispose(); } public void asignarImagen() { screenLabel.setIcon(new ImageIcon(p.getImageActual())); } public Editar() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); txtBuscarX = new javax.swing.JTextField(); txtBuscarY = new javax.swing.JTextField(); jPanel3 = new javax.swing.JPanel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); txtValorR = new javax.swing.JTextField(); txtValorG = new javax.swing.JTextField(); txtValorB = new javax.swing.JTextField(); btnCambierRgb = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jPanel5 = new javax.swing.JPanel(); labelPuntoActual = new javax.swing.JLabel(); labelDmiencion = new javax.swing.JLabel(); labelProm = new javax.swing.JLabel(); labelPromR = new javax.swing.JLabel(); labelPromG = new javax.swing.JLabel(); labelPromB = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); screenLabel = new javax.swing.JLabel(); jMenuBar1 = new javax.swing.JMenuBar(); menuArchivo = new javax.swing.JMenu(); jMenuItem1 = new javax.swing.JMenuItem(); jMenuItem2 = new javax.swing.JMenuItem(); jMenuItem3 = new javax.swing.JMenuItem(); menuHerramientas = new javax.swing.JMenu(); jMenuItemRestaurar = new javax.swing.JMenuItem(); jMenuItemHistograma = new javax.swing.JMenuItem(); jMenu7 = new javax.swing.JMenu(); jMenuItem5 = new javax.swing.JMenuItem(); jMenuItem21 = new javax.swing.JMenuItem(); jMenuItem22 = new javax.swing.JMenuItem(); jMenuItem35 = new javax.swing.JMenuItem(); jMenuItem4 = new javax.swing.JMenuItem(); jMenuItem12 = new javax.swing.JMenuItem(); menuNegativo = new javax.swing.JMenuItem(); crearMenuItem = new javax.swing.JMenu(); circuloMenuItem = new javax.swing.JMenuItem(); cuadradoMenuItem = new javax.swing.JMenuItem(); grisesMenuItem = new javax.swing.JMenuItem(); coloresMenuItem = new javax.swing.JMenuItem(); menuRuido = new javax.swing.JMenu(); jMenuItem6 = new javax.swing.JMenuItem(); jMenuItem7 = new javax.swing.JMenuItem(); jMenuItem8 = new javax.swing.JMenuItem(); jMenuItemSalYPimienta = new javax.swing.JMenuItem(); jMenu5 = new javax.swing.JMenu(); jMenuItem9 = new javax.swing.JMenuItem(); jMenuItem10 = new javax.swing.JMenuItem(); jMenuItem11 = new javax.swing.JMenuItem(); menuOperaciones = new javax.swing.JMenu(); menuSuma = new javax.swing.JMenuItem(); menuResta = new javax.swing.JMenuItem(); menuProducto = new javax.swing.JMenuItem(); menuEscalar = new javax.swing.JMenuItem(); menuDinamico = new javax.swing.JMenuItem(); menuPotencia = new javax.swing.JMenuItem(); menuFiltros = new javax.swing.JMenu(); menuMediana = new javax.swing.JMenuItem(); menuMedia = new javax.swing.JMenuItem(); menuGauss = new javax.swing.JMenuItem(); menuBordes = new javax.swing.JMenuItem(); jMenuItem19 = new javax.swing.JMenuItem(); jMenuAnisotropica = new javax.swing.JMenu(); jMenuItemLeclerc = new javax.swing.JMenuItem(); jMenuItemLorentz = new javax.swing.JMenuItem(); jMenuDetectoresDeBorde = new javax.swing.JMenu(); jMenuPrewitt = new javax.swing.JMenu(); jMenuItem13 = new javax.swing.JMenuItem(); jMenuItem14 = new javax.swing.JMenuItem(); jMenuItem15 = new javax.swing.JMenuItem(); jMenuSobel = new javax.swing.JMenu(); jMenuItem16 = new javax.swing.JMenuItem(); jMenuItem17 = new javax.swing.JMenuItem(); jMenuItem18 = new javax.swing.JMenuItem(); jMenuDireccionales = new javax.swing.JMenu(); Personalizado = new javax.swing.JMenuItem(); jMenuKirsh = new javax.swing.JMenuItem(); jMenuItemPrewitt = new javax.swing.JMenuItem(); jMenuSobelDireccional = new javax.swing.JMenuItem(); jMenuLaplaciano = new javax.swing.JMenu(); jMenuItem23 = new javax.swing.JMenuItem(); jMenuItem24 = new javax.swing.JMenuItem(); jMenuItem20 = new javax.swing.JMenuItem(); jMenuItem25 = new javax.swing.JMenuItem(); jMenu2 = new javax.swing.JMenu(); jMenuItem27 = new javax.swing.JMenuItem(); jMenuItem29 = new javax.swing.JMenuItem(); jMenuItem30 = new javax.swing.JMenuItem(); jMenu3 = new javax.swing.JMenu(); jMenuItem31 = new javax.swing.JMenuItem(); jMenuItem32 = new javax.swing.JMenuItem(); jMenuItem33 = new javax.swing.JMenuItem(); jMenu1 = new javax.swing.JMenu(); jMenuItem26 = new javax.swing.JMenuItem(); jMenu4 = new javax.swing.JMenu(); jMenu6 = new javax.swing.JMenu(); jMenuItem34 = new javax.swing.JMenuItem(); jMenuItemIsRobusto = new javax.swing.JCheckBoxMenuItem(); setClosable(true); setIconifiable(true); setMaximizable(true); setResizable(true); jPanel1.setName("PanPrincipal"); // NOI18N jPanel2.setName("Controlador"); // NOI18N jLabel1.setText("Buscar pixel por coordenadas:"); jLabel2.setText("X:"); jLabel3.setText("Y:"); txtBuscarX.setName("txtPixelX"); // NOI18N txtBuscarX.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtBuscarXActionPerformed(evt); } }); txtBuscarY.setName("txtPixelY"); // NOI18N jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Valores:")); jLabel4.setText("R:"); jLabel5.setText("G:"); jLabel6.setText("B:"); btnCambierRgb.setText("cambiar"); btnCambierRgb.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCambierRgbActionPerformed(evt); } }); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addGap(22, 22, 22) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addComponent(jLabel6) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtValorB, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel3Layout.createSequentialGroup().addComponent(jLabel5) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtValorG, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel3Layout.createSequentialGroup().addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtValorR, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(92, Short.MAX_VALUE)) .addComponent(btnCambierRgb, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addGap(11, 11, 11) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4).addComponent(txtValorR, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel5).addComponent(txtValorG, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel6) .addComponent(txtValorB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnCambierRgb).addContainerGap())); jButton2.setText("Obtener"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Informacion")); labelProm.setText("Promedio: "); javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup(jPanel5Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(labelDmiencion, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE) .addComponent(labelPuntoActual, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(labelProm, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(labelPromR, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(labelPromG, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(labelPromB, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(0, 72, Short.MAX_VALUE))); jPanel5Layout .setVerticalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addComponent(labelPuntoActual, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(labelDmiencion, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(labelProm, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(labelPromR, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(labelPromG, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(labelPromB, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(24, Short.MAX_VALUE))); jButton1.setText("Guardar"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1) .addGroup(jPanel2Layout.createSequentialGroup().addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtBuscarX, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18).addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtBuscarY, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel2Layout.createSequentialGroup().addGap(36, 36, 36).addComponent( jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addComponent(jLabel1).addGap(18, 18, 18) .addGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2).addComponent(jLabel3) .addComponent(txtBuscarX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtBuscarY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton1))) .addContainerGap(186, Short.MAX_VALUE))); screenLabel.setBackground(new java.awt.Color(255, 255, 255)); screenLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); screenLabel.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { screenLabelMouseClicked(evt); } public void mouseEntered(java.awt.event.MouseEvent evt) { screenLabelMouseEntered(evt); } public void mousePressed(java.awt.event.MouseEvent evt) { screenLabelMousePressed(evt); } }); screenLabel.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { public void mouseDragged(java.awt.event.MouseEvent evt) { screenLabelMouseDragged(evt); } public void mouseMoved(java.awt.event.MouseEvent evt) { screenLabelMouseMoved(evt); } }); jScrollPane1.setViewportView(screenLabel); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout .setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 386, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(38, 38, 38))); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGap(12, 12, 12) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 301, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))); menuArchivo.setText("Archivo"); jMenuItem1.setText("Guardar"); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); menuArchivo.add(jMenuItem1); jMenuItem2.setText("Guardar como"); menuArchivo.add(jMenuItem2); jMenuItem3.setText("Mostrar Imagen"); jMenuItem3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem3ActionPerformed(evt); } }); menuArchivo.add(jMenuItem3); jMenuBar1.add(menuArchivo); menuHerramientas.setText("Herramientas"); jMenuItemRestaurar.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.CTRL_MASK)); jMenuItemRestaurar.setText("Restaurar Imagen"); jMenuItemRestaurar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemRestaurarActionPerformed(evt); } }); menuHerramientas.add(jMenuItemRestaurar); jMenuItemHistograma.setText("Histograma"); jMenuItemHistograma.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemHistogramaActionPerformed(evt); } }); menuHerramientas.add(jMenuItemHistograma); jMenu7.setText("Umbralizar"); jMenuItem5.setText("Umbralizar definido"); jMenuItem5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem5ActionPerformed(evt); } }); jMenu7.add(jMenuItem5); jMenuItem21.setText("Umbralizacin Global"); jMenuItem21.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem21ActionPerformed(evt); } }); jMenu7.add(jMenuItem21); jMenuItem22.setText("Umbralizacin de Otsu"); jMenuItem22.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem22ActionPerformed(evt); } }); jMenu7.add(jMenuItem22); jMenuItem35.setText("Umbralizacion Color"); jMenuItem35.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem35ActionPerformed(evt); } }); jMenu7.add(jMenuItem35); menuHerramientas.add(jMenu7); jMenuItem4.setText("Ecualizar"); jMenuItem4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem4ActionPerformed(evt); } }); menuHerramientas.add(jMenuItem4); jMenuItem12.setText("Aumentar Contraste"); jMenuItem12.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem12ActionPerformed(evt); } }); menuHerramientas.add(jMenuItem12); menuNegativo.setText("Negativo"); menuNegativo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuNegativoActionPerformed(evt); } }); menuHerramientas.add(menuNegativo); crearMenuItem.setText("Crear"); circuloMenuItem.setText("Circulo"); circuloMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { circuloMenuItemActionPerformed(evt); } }); crearMenuItem.add(circuloMenuItem); cuadradoMenuItem.setText("Cuadrado"); cuadradoMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cuadradoMenuItemActionPerformed(evt); } }); crearMenuItem.add(cuadradoMenuItem); grisesMenuItem.setText("Degradado Grises"); grisesMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { grisesMenuItemActionPerformed(evt); } }); crearMenuItem.add(grisesMenuItem); coloresMenuItem.setText("Degradado Colores"); coloresMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { coloresMenuItemActionPerformed(evt); } }); crearMenuItem.add(coloresMenuItem); menuHerramientas.add(crearMenuItem); jMenuBar1.add(menuHerramientas); menuRuido.setText("Ruido"); jMenuItem6.setText("Gaussiano"); jMenuItem6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem6ActionPerformed(evt); } }); menuRuido.add(jMenuItem6); jMenuItem7.setText("Rayleigh"); jMenuItem7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem7ActionPerformed(evt); } }); menuRuido.add(jMenuItem7); jMenuItem8.setText("Exponencial"); jMenuItem8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem8ActionPerformed(evt); } }); menuRuido.add(jMenuItem8); jMenuItemSalYPimienta.setText("Sal Y Pimienta"); jMenuItemSalYPimienta.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemSalYPimientaActionPerformed(evt); } }); menuRuido.add(jMenuItemSalYPimienta); jMenu5.setText("Sinteticas"); jMenuItem9.setText("Gaussiano"); jMenuItem9.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem9ActionPerformed(evt); } }); jMenu5.add(jMenuItem9); jMenuItem10.setText("Rayleigh"); jMenuItem10.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem10ActionPerformed(evt); } }); jMenu5.add(jMenuItem10); jMenuItem11.setText("Exponencial"); jMenuItem11.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem11ActionPerformed(evt); } }); jMenu5.add(jMenuItem11); menuRuido.add(jMenu5); jMenuBar1.add(menuRuido); menuOperaciones.setText("Operaciones"); menuSuma.setText("Sumar"); menuSuma.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuSumaActionPerformed(evt); } }); menuOperaciones.add(menuSuma); menuResta.setText("Restar"); menuResta.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuRestaActionPerformed(evt); } }); menuOperaciones.add(menuResta); menuProducto.setText("Producto"); menuProducto.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuProductoActionPerformed(evt); } }); menuOperaciones.add(menuProducto); menuEscalar.setText("Producto Escalar"); menuEscalar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuEscalarActionPerformed(evt); } }); menuOperaciones.add(menuEscalar); menuDinamico.setText("Rango Dinamico"); menuDinamico.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuDinamicoActionPerformed(evt); } }); menuOperaciones.add(menuDinamico); menuPotencia.setText("Potencia Gamma"); menuPotencia.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuPotenciaActionPerformed(evt); } }); menuOperaciones.add(menuPotencia); jMenuBar1.add(menuOperaciones); menuFiltros.setText("Filtros"); menuMediana.setText("Mediana"); menuMediana.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuMedianaActionPerformed(evt); } }); menuFiltros.add(menuMediana); menuMedia.setText("Media"); menuMedia.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuMediaActionPerformed(evt); } }); menuFiltros.add(menuMedia); menuGauss.setText("Gauss"); menuGauss.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuGaussActionPerformed(evt); } }); menuFiltros.add(menuGauss); menuBordes.setText("Realce de Bordes"); menuBordes.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuBordesActionPerformed(evt); } }); menuFiltros.add(menuBordes); jMenuItem19.setText("Difusin Isotrpica"); jMenuItem19.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem19ActionPerformed(evt); } }); menuFiltros.add(jMenuItem19); jMenuAnisotropica.setText("Difusin Anisotropica"); jMenuItemLeclerc.setText("Detector De Bordes Leclerc"); jMenuItemLeclerc.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemLeclercActionPerformed(evt); } }); jMenuAnisotropica.add(jMenuItemLeclerc); jMenuItemLorentz.setText("Detector De Bordes Lorentz"); jMenuItemLorentz.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemLorentzActionPerformed(evt); } }); jMenuAnisotropica.add(jMenuItemLorentz); menuFiltros.add(jMenuAnisotropica); jMenuBar1.add(menuFiltros); jMenuDetectoresDeBorde.setText("Detectores De Borde"); jMenuPrewitt.setText("Prewitt"); jMenuItem13.setText("Mostrar En X,Y"); jMenuItem13.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem13ActionPerformed(evt); } }); jMenuPrewitt.add(jMenuItem13); jMenuItem14.setText("Mostrar En X"); jMenuItem14.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem14ActionPerformed(evt); } }); jMenuPrewitt.add(jMenuItem14); jMenuItem15.setText("Mostrar En Y"); jMenuItem15.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem15ActionPerformed(evt); } }); jMenuPrewitt.add(jMenuItem15); jMenuDetectoresDeBorde.add(jMenuPrewitt); jMenuSobel.setText("Sobel"); jMenuItem16.setText("Mostrar En X,Y"); jMenuItem16.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem16ActionPerformed(evt); } }); jMenuSobel.add(jMenuItem16); jMenuItem17.setText("Mostrar En X"); jMenuItem17.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem17ActionPerformed(evt); } }); jMenuSobel.add(jMenuItem17); jMenuItem18.setText("Mostrar En Y"); jMenuItem18.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem18ActionPerformed(evt); } }); jMenuSobel.add(jMenuItem18); jMenuDetectoresDeBorde.add(jMenuSobel); jMenuDireccionales.setText("Direccionales"); Personalizado.setText("Personalizado"); Personalizado.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { PersonalizadoActionPerformed(evt); } }); jMenuDireccionales.add(Personalizado); jMenuKirsh.setText("Kirsh"); jMenuKirsh.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuKirshActionPerformed(evt); } }); jMenuDireccionales.add(jMenuKirsh); jMenuItemPrewitt.setText("Prewitt"); jMenuItemPrewitt.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemPrewittActionPerformed(evt); } }); jMenuDireccionales.add(jMenuItemPrewitt); jMenuSobelDireccional.setText("Sobel"); jMenuSobelDireccional.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuSobelDireccionalActionPerformed(evt); } }); jMenuDireccionales.add(jMenuSobelDireccional); jMenuDetectoresDeBorde.add(jMenuDireccionales); jMenuLaplaciano.setText("Laplaciano"); jMenuItem23.setText("Mascara"); jMenuItem23.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem23ActionPerformed(evt); } }); jMenuLaplaciano.add(jMenuItem23); jMenuItem24.setText("Curces Por Cero"); jMenuItem24.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem24ActionPerformed(evt); } }); jMenuLaplaciano.add(jMenuItem24); jMenuItem20.setText("Mascara de LoG"); jMenuItem20.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem20ActionPerformed(evt); } }); jMenuLaplaciano.add(jMenuItem20); jMenuItem25.setText("Gausiano (Marr-Hildreth)"); jMenuItem25.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem25ActionPerformed(evt); } }); jMenuLaplaciano.add(jMenuItem25); jMenuDetectoresDeBorde.add(jMenuLaplaciano); jMenu2.setText("Canny"); jMenuItem27.setText("No Maximos"); jMenuItem27.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem27ActionPerformed(evt); } }); jMenu2.add(jMenuItem27); jMenuItem29.setText("Aplicar Canny"); jMenuItem29.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem29ActionPerformed(evt); } }); jMenu2.add(jMenuItem29); jMenuDetectoresDeBorde.add(jMenu2); jMenuItem30.setText("SUSAN"); jMenuItem30.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem30ActionPerformed(evt); } }); jMenuDetectoresDeBorde.add(jMenuItem30); jMenu3.setText("Transformada Hough"); jMenuItem31.setText("Rectas"); jMenuItem31.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem31ActionPerformed(evt); } }); jMenu3.add(jMenuItem31); jMenuItem32.setText("Circulos"); jMenuItem32.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem32ActionPerformed(evt); } }); jMenu3.add(jMenuItem32); jMenuDetectoresDeBorde.add(jMenu3); jMenuItem33.setText("Harris"); jMenuItem33.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem33ActionPerformed(evt); } }); jMenuDetectoresDeBorde.add(jMenuItem33); jMenuBar1.add(jMenuDetectoresDeBorde); jMenu1.setText("Segmentar"); jMenu1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenu1ActionPerformed(evt); } }); jMenuItem26.setText("Segmentar Imagen"); jMenuItem26.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem26ActionPerformed(evt); } }); jMenu1.add(jMenuItem26); jMenuBar1.add(jMenu1); jMenu4.setText("Sift"); jMenu6.setText("Aplicar SIFT"); jMenuItem34.setText("Abrir Imagen"); jMenuItem34.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem34ActionPerformed(evt); } }); jMenu6.add(jMenuItem34); jMenuItemIsRobusto.setSelected(true); jMenuItemIsRobusto.setText("Robusto"); jMenuItemIsRobusto.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemIsRobustoActionPerformed(evt); } }); jMenu6.add(jMenuItemIsRobusto); jMenu4.add(jMenu6); jMenuBar1.add(jMenu4); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); pack(); }// </editor-fold>//GEN-END:initComponents private void txtBuscarXActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtBuscarXActionPerformed // TODO add your handling code here: }//GEN-LAST:event_txtBuscarXActionPerformed private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jMenuItem1ActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed int x = Integer.parseInt(txtBuscarX.getText()); int y = Integer.parseInt(txtBuscarY.getText()); Color c = p.valorPixel(screen, x, y); txtValorR.setText(String.valueOf(c.getRed())); txtValorG.setText(String.valueOf(c.getGreen())); txtValorB.setText(String.valueOf(c.getBlue())); }//GEN-LAST:event_jButton2ActionPerformed private void btnCambierRgbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCambierRgbActionPerformed int x = Integer.parseInt(txtBuscarX.getText()); int y = Integer.parseInt(txtBuscarY.getText()); int valorR = Integer.parseInt(txtValorR.getText()); int valorG = Integer.parseInt(txtValorG.getText()); int valorB = Integer.parseInt(txtValorB.getText()); BufferedImage b = p.cambiarPixel(x, y, valorR, valorG, valorB); seleccionarRectangulo(b); screenLabel.repaint(); }//GEN-LAST:event_btnCambierRgbActionPerformed private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed Visor v = new Visor(p); JDesktopPane parentPanel = (JDesktopPane) this.getParent(); parentPanel.add(v); v.setVisible(true); }//GEN-LAST:event_jMenuItem3ActionPerformed private void screenLabelMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_screenLabelMouseMoved start = evt.getPoint(); repaint(screen, screenCopy); labelPuntoActual.setText("Punto: X: " + start.x + ",Y: " + start.y); screenLabel.repaint(); }//GEN-LAST:event_screenLabelMouseMoved private void screenLabelMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_screenLabelMouseDragged end = evt.getPoint(); captureRect = new Rectangle(startClick, new Dimension(end.x - startClick.x, end.y - startClick.y)); repaint(screen, screenCopy); labelDmiencion.setText("Ancho: " + captureRect.width + " ,Largo: " + captureRect.height); screenLabel.repaint(); float promedioR = 0, promedioG = 0, promedioB = 0; int sumR = 0, sumG = 0, sumB = 0, count = 0; Color c; for (int i = startClick.x; i < end.x; i++) { for (int j = startClick.y; j < end.y; j++) { c = new Color(screen.getRGB(i, j)); count++; sumR = sumR + c.getRed(); sumG = sumG + c.getGreen(); sumB = sumB + c.getBlue(); } } promedioR = (float) sumR / (float) count; promedioG = (float) sumG / (float) count; promedioB = (float) sumB / (float) count; labelPromR.setText("R: " + promedioR); labelPromG.setText("G: " + promedioG); labelPromB.setText("B: " + promedioB); }//GEN-LAST:event_screenLabelMouseDragged private void screenLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_screenLabelMouseClicked }//GEN-LAST:event_screenLabelMouseClicked private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed System.out.println(startClick.x + " " + startClick.y + " " + captureRect.width + " " + captureRect.height); BufferedImage image = screen.getSubimage(startClick.x, startClick.y, captureRect.width, captureRect.height); chooseSaveFile(image); }//GEN-LAST:event_jButton1ActionPerformed private void screenLabelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_screenLabelMouseEntered }//GEN-LAST:event_screenLabelMouseEntered private void screenLabelMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_screenLabelMousePressed startClick = evt.getPoint(); int x = startClick.x; int y = startClick.y; txtBuscarX.setText(String.valueOf(x)); txtBuscarY.setText(String.valueOf(y)); Color c = p.valorPixel(screen, x, y); txtValorR.setText(String.valueOf(c.getRed())); txtValorG.setText(String.valueOf(c.getGreen())); txtValorB.setText(String.valueOf(c.getBlue())); }//GEN-LAST:event_screenLabelMousePressed private void jMenuItemHistogramaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemHistogramaActionPerformed objHistograma = new Histograma2(screen); objVentanaHistograma.canvasHistograma.pintarHistograma(objHistograma.getImageHistograma()); objVentanaHistograma.pack(); //parentPanel.add(objVentanaHistograma); objVentanaHistograma.setVisible(true); }//GEN-LAST:event_jMenuItemHistogramaActionPerformed private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed try { String res = JOptionPane.showInputDialog(this, "Valor Del Umbral: "); int resNum = Integer.parseInt(res); if (resNum > -1 && resNum < 256) { seleccionarRectangulo(p.umbralizarGrises(screen, resNum)); } else { JOptionPane.showMessageDialog(this, "Ingrese Un Numero Entre 0 y 255"); } } catch (Exception e) { JOptionPane.showMessageDialog(this, "Ingrese Un Numero Entre 0 y 255"); } }//GEN-LAST:event_jMenuItem5ActionPerformed private void jMenuItemRestaurarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemRestaurarActionPerformed seleccionarRectangulo(p.getImageActual()); }//GEN-LAST:event_jMenuItemRestaurarActionPerformed private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed seleccionarRectangulo(p.ecualizarGris(screen)); }//GEN-LAST:event_jMenuItem4ActionPerformed private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed try { String sigma = JOptionPane.showInputDialog(this, "Valor De Sigma"); //String mu = JOptionPane.showInputDialog(this, "Valor De Mu"); int sigmaInt = Integer.parseInt(sigma); //int muInt = Integer.parseInt(mu); seleccionarRectangulo(GeneradorDeRuido.generarRuidoGauss(screen, sigmaInt, 1)); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Ingrese Solo Valores Numericos."); e.printStackTrace(); } }//GEN-LAST:event_jMenuItem6ActionPerformed private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed try { String phi = JOptionPane.showInputDialog(this, "Valor De Phi"); int phiInt = Integer.parseInt(phi); seleccionarRectangulo(GeneradorDeRuido.generarRuidoRayleighMultiplicativo(screen, phiInt)); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Ingrese Solo Valores Numericos."); e.printStackTrace(); } }//GEN-LAST:event_jMenuItem7ActionPerformed private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed try { String lamba = JOptionPane.showInputDialog(this, "Valor De Lambda"); int lambaInt = Integer.parseInt(lamba); seleccionarRectangulo(GeneradorDeRuido.generarRuidoExponencialMultiplicativo(screen, lambaInt)); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Ingrese Solo Valores Numericos."); e.printStackTrace(); } }//GEN-LAST:event_jMenuItem8ActionPerformed private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed try { String sigma = JOptionPane.showInputDialog(this, "Valor De Sigma"); String mu = JOptionPane.showInputDialog(this, "Valor De Mu"); int sigmaInt = Integer.parseInt(sigma); int muInt = Integer.parseInt(mu); seleccionarRectangulo(GeneradorDeRuido .generarRuidoGauss(new BufferedImage(100, 100, BufferedImage.TYPE_3BYTE_BGR), sigmaInt, muInt)); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Ingrese Solo Valores Numericos."); e.printStackTrace(); } }//GEN-LAST:event_jMenuItem9ActionPerformed private void jMenuItem10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem10ActionPerformed try { String phi = JOptionPane.showInputDialog(this, "Valor De Phi"); int phiInt = Integer.parseInt(phi); seleccionarRectangulo(GeneradorDeRuido.generarRuidoRayleighMultiplicativo( p.generarImagenSinteticaMultiplicativa(100, 100, 1), phiInt)); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Ingrese Solo Valores Numericos."); e.printStackTrace(); } }//GEN-LAST:event_jMenuItem10ActionPerformed private void jMenuItem11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem11ActionPerformed try { String lamba = JOptionPane.showInputDialog(this, "Valor De Lambda"); int lambaInt = Integer.parseInt(lamba); seleccionarRectangulo(GeneradorDeRuido.generarRuidoExponencialMultiplicativo( p.generarImagenSinteticaMultiplicativa(100, 100, 100), lambaInt)); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Ingrese Solo Valores Numericos."); e.printStackTrace(); } }//GEN-LAST:event_jMenuItem11ActionPerformed private void jMenuItemSalYPimientaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSalYPimientaActionPerformed try { String por = JOptionPane.showInputDialog(this, "Porcentage De Pixeles"); int porInt = Integer.parseInt(por); seleccionarRectangulo(GeneradorDeRuido.generarRuidoSaltAndPepper(screen, porInt)); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Ingrese Solo Valores Numericos."); e.printStackTrace(); } }//GEN-LAST:event_jMenuItemSalYPimientaActionPerformed private void menuSumaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuSumaActionPerformed // TODO add your handling code here: BufferedImage bmp = null; JFileChooser fileChooser = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG", "PNG", "jpg", "png"); fileChooser.setFileFilter(filter); fileChooser.setAcceptAllFileFilterUsed(false); int respu = fileChooser.showOpenDialog(this); if (respu == JFileChooser.APPROVE_OPTION && fileChooser.getSelectedFile().exists()) { try { //Devuelve el fichero seleccionado File imagenSeleccionada = fileChooser.getSelectedFile(); //Asignamos a la variable bmp la imagen leida bmp = ImageIO.read(imagenSeleccionada); } catch (IOException ex) { Logger.getLogger(Editar.class.getName()).log(Level.SEVERE, null, ex); } } // screenCopy = p.escalaGrises(bmp); if (screen.getWidth() == screenCopy.getWidth() && screen.getHeight() == screenCopy.getHeight()) { seleccionarRectangulo(Op.suma(screen, bmp)); } else { JOptionPane.showConfirmDialog(this, "Las imgenes no coinciden"); } }//GEN-LAST:event_menuSumaActionPerformed private void menuRestaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuRestaActionPerformed // TODO add your handling code here: BufferedImage bmp = null; JFileChooser fileChooser = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG", "jpg", "png"); fileChooser.setFileFilter(filter); fileChooser.setAcceptAllFileFilterUsed(false); int respu = fileChooser.showOpenDialog(this); if (respu == JFileChooser.APPROVE_OPTION && fileChooser.getSelectedFile().exists()) { try { //Devuelve el fichero seleccionado File imagenSeleccionada = fileChooser.getSelectedFile(); //Asignamos a la variable bmp la imagen leida bmp = ImageIO.read(imagenSeleccionada); } catch (IOException ex) { Logger.getLogger(Editar.class.getName()).log(Level.SEVERE, null, ex); } } //imageSegunda = p.escalaGrises(bmp); if (screen.getWidth() == bmp.getWidth() && screen.getHeight() == bmp.getHeight()) { seleccionarRectangulo(Op.resta(screen, bmp)); //repaint(screen, screenCopy); } else { JOptionPane.showConfirmDialog(this, "Las imgenes no coinciden"); } }//GEN-LAST:event_menuRestaActionPerformed private void menuProductoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuProductoActionPerformed // TODO add your handling code here: BufferedImage bmp = null; JFileChooser fileChooser = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG", "jpg", "png"); fileChooser.setFileFilter(filter); fileChooser.setAcceptAllFileFilterUsed(false); int respu = fileChooser.showOpenDialog(this); if (respu == JFileChooser.APPROVE_OPTION && fileChooser.getSelectedFile().exists()) { try { //Devuelve el fichero seleccionado File imagenSeleccionada = fileChooser.getSelectedFile(); //Asignamos a la variable bmp la imagen leida bmp = ImageIO.read(imagenSeleccionada); } catch (IOException ex) { Logger.getLogger(Editar.class.getName()).log(Level.SEVERE, null, ex); } } //imageSegunda = p.escalaGrises(bmp); if (screen.getWidth() == bmp.getWidth() && screen.getHeight() == bmp.getHeight()) { seleccionarRectangulo(Op.producto(screen, bmp)); // repaint(screen, screenCopy); System.out.println("Si multiplica imagenes"); } else { JOptionPane.showConfirmDialog(this, "Las imgenes no coinciden"); } }//GEN-LAST:event_menuProductoActionPerformed private void menuEscalarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuEscalarActionPerformed // TODO add your handling code here: String valor = JOptionPane.showInputDialog(this, "Valor", "Multiplicar Valor A Imagen", JOptionPane.INFORMATION_MESSAGE); int constante = Integer.parseInt(valor); seleccionarRectangulo(Op.producto(screen, constante)); System.out.println("Si Multiplica Constante"); }//GEN-LAST:event_menuEscalarActionPerformed private void menuDinamicoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuDinamicoActionPerformed // TODO add your handling code here: //R valor mximo de gris en la imgen seleccionarRectangulo(Op.rangoDinamico(screen)); // repaint(screen, screenCopy); System.out.println("si comprime el Rango dinamico"); }//GEN-LAST:event_menuDinamicoActionPerformed private void menuPotenciaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuPotenciaActionPerformed // TODO add your handling code here: String valor = JOptionPane.showInputDialog(this, "Valor", "Definir el valor de ", JOptionPane.INFORMATION_MESSAGE); double gamma; gamma = Double.parseDouble(valor); seleccionarRectangulo(Op.powerLaw(screen, gamma)); System.out.println("Si transforma potencia"); }//GEN-LAST:event_menuPotenciaActionPerformed private void menuMedianaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuMedianaActionPerformed // TODO add your handling code here: String valor = JOptionPane.showInputDialog(this, "Tamao de mscara", "Definir el tamao de mascara", JOptionPane.INFORMATION_MESSAGE); int sizeM = Integer.parseInt(valor); if (sizeM % 2 == 0 || sizeM == 1) { JOptionPane.showMessageDialog(null, "Favor ingresar un numero IMPAR o mayor a 1"); } else { seleccionarRectangulo(f.mediana(screen, sizeM)); System.out.println("Filtro Mediana OK"); } }//GEN-LAST:event_menuMedianaActionPerformed private void menuGaussActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuGaussActionPerformed // TODO add your handling code here: Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); String valor = JOptionPane.showInputDialog(this, "Valor de sigma", "Definir el valor de sigma", JOptionPane.INFORMATION_MESSAGE); int sSigma = Integer.parseInt(valor); Imagen imagenFiltrada = FiltroGaussiano.aplicarFiltroGaussiano(imagenScreen, sSigma); seleccionarRectangulo(imagenFiltrada.getBufferedImage()); System.out.println("Filtro Gaussiano OK"); }//GEN-LAST:event_menuGaussActionPerformed private void menuMediaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuMediaActionPerformed // TODO add your handling code here: String valor = JOptionPane.showInputDialog(this, "Tamao de mscara", "Definir el tamao de mascara", JOptionPane.INFORMATION_MESSAGE); int sizeM = Integer.parseInt(valor); if (sizeM % 2 == 0 || sizeM == 1) { JOptionPane.showMessageDialog(null, "Favor ingresar un numero IMPAR o mayor a 1"); } else { seleccionarRectangulo(f.media(screen, sizeM)); System.out.println("Filtro Media OK"); } }//GEN-LAST:event_menuMediaActionPerformed private void menuBordesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuBordesActionPerformed // TODO add your handling code here: seleccionarRectangulo(f.bordes(screen)); System.out.println("Filtro PasaAltos OK"); }//GEN-LAST:event_menuBordesActionPerformed private void jMenuItem12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem12ActionPerformed // TODO add your handling code here: try { String res = JOptionPane.showInputDialog(this, "Valor Del rango: "); int resNum = Integer.parseInt(res); if (resNum > 0 && resNum < 128) { seleccionarRectangulo(p.contraste(screen, resNum)); } else { JOptionPane.showMessageDialog(this, "Ingrese Un Numero Entre 0 y 128"); } } catch (Exception e) { JOptionPane.showMessageDialog(this, "Ingrese Un Numero Entre 0 y 255"); e.printStackTrace(); } }//GEN-LAST:event_jMenuItem12ActionPerformed private void menuNegativoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuNegativoActionPerformed // TODO add your handling code here: seleccionarRectangulo(f.negativo(screen)); System.out.println("negativo OK"); }//GEN-LAST:event_menuNegativoActionPerformed private void jMenuItem13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem13ActionPerformed Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.GIF, "hola"); BufferedImage prewitt = DetectorDeBordes.aplicarDetectorDePrewitt(imagenScreen); seleccionarRectangulo(prewitt); }//GEN-LAST:event_jMenuItem13ActionPerformed private void jMenuItem14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem14ActionPerformed Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); BufferedImage prewittEnX = DetectorDeBordes.mostrarMascaraDePrewittEnX(imagenScreen); seleccionarRectangulo(prewittEnX); }//GEN-LAST:event_jMenuItem14ActionPerformed private void jMenuItem15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem15ActionPerformed Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); BufferedImage prewittEnY = DetectorDeBordes.mostrarMascaraDePrewittEnY(imagenScreen); seleccionarRectangulo(prewittEnY); }//GEN-LAST:event_jMenuItem15ActionPerformed private void jMenuItem16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem16ActionPerformed Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); BufferedImage sobel = DetectorDeBordes.aplicarDetectorDeSobel(imagenScreen); seleccionarRectangulo(sobel); }//GEN-LAST:event_jMenuItem16ActionPerformed private void jMenuItem17ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem17ActionPerformed Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); BufferedImage sobelX = DetectorDeBordes.mostrarMascaraDeSobelEnX(imagenScreen); seleccionarRectangulo(sobelX); }//GEN-LAST:event_jMenuItem17ActionPerformed private void jMenuItem18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem18ActionPerformed Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); BufferedImage sobelY = DetectorDeBordes.mostrarMascaraDeSobelEnY(imagenScreen); seleccionarRectangulo(sobelY); }//GEN-LAST:event_jMenuItem18ActionPerformed private void PersonalizadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PersonalizadoActionPerformed Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); BufferedImage direccionalPerzonalizado = DetectorDeBordesDireccionales .aplicarDetectorDeBordesDireccional(imagenScreen, "Nueva"); seleccionarRectangulo(direccionalPerzonalizado); }//GEN-LAST:event_PersonalizadoActionPerformed private void jMenuKirshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuKirshActionPerformed Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); BufferedImage direccionalKirsh = DetectorDeBordesDireccionales .aplicarDetectorDeBordesDireccional(imagenScreen, "Kirsh"); seleccionarRectangulo(direccionalKirsh); }//GEN-LAST:event_jMenuKirshActionPerformed private void jMenuSobelDireccionalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuSobelDireccionalActionPerformed Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); BufferedImage direccionalSobel = DetectorDeBordesDireccionales .aplicarDetectorDeBordesDireccional(imagenScreen, "Sobel"); seleccionarRectangulo(direccionalSobel); }//GEN-LAST:event_jMenuSobelDireccionalActionPerformed private void jMenuItemPrewittActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemPrewittActionPerformed Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); BufferedImage direccionalPrewitt = DetectorDeBordesDireccionales .aplicarDetectorDeBordesDireccional(imagenScreen, "Prewitt"); seleccionarRectangulo(direccionalPrewitt); }//GEN-LAST:event_jMenuItemPrewittActionPerformed private void jMenuItem23ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem23ActionPerformed // TODO add your handling code here: Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); BufferedImage mascaraLaplaciano = DetectorDeBordes.mostrarMascaraDeLaplaciano(imagenScreen); seleccionarRectangulo(mascaraLaplaciano); }//GEN-LAST:event_jMenuItem23ActionPerformed private void jMenuItem19ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem19ActionPerformed try { String repeticiones = JOptionPane.showInputDialog(this, "Numero De Repteciones: "); int repNum = Integer.parseInt(repeticiones); if (repNum > 0) { BufferedImage bufferedImage = Difuminador.aplicarDifusion(screen, null, repNum, true); seleccionarRectangulo(bufferedImage); } else { JOptionPane.showMessageDialog(this, "Ingrese Un Superior a 0"); } } catch (Exception e) { JOptionPane.showMessageDialog(this, "Ingrese Un Numero Superior a 0"); e.printStackTrace(); } }//GEN-LAST:event_jMenuItem19ActionPerformed private void aplicarAnisotropica(boolean isLeclerc) { InterfaceDetectorDeBordes detectorDeBordes = null; try { String repeticiones = JOptionPane.showInputDialog(this, "Numero De Repeticiones: "); String sigma = JOptionPane.showInputDialog(this, "Ingrese Sigma"); int repNum = Integer.parseInt(repeticiones); int sigmaNum = Integer.parseInt(sigma); if (repNum > 0 || sigmaNum < 0) { if (isLeclerc) { detectorDeBordes = new DetectorDeBordesLeclerc(sigmaNum); } else { detectorDeBordes = new DetectorDeBordesLorentz(sigmaNum); } BufferedImage bufferedImage = Difuminador.aplicarDifusion(screen, detectorDeBordes, repNum, false); seleccionarRectangulo(bufferedImage); } else { JOptionPane.showMessageDialog(this, "Ingrese Un Superior a 0"); } } catch (Exception e) { JOptionPane.showMessageDialog(this, "Ingrese Un Numero Superior a 0"); e.printStackTrace(); } } private void jMenuItemLeclercActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemLeclercActionPerformed aplicarAnisotropica(true); //hola }//GEN-LAST:event_jMenuItemLeclercActionPerformed private void jMenuItem24ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem24ActionPerformed // TODO add your handling code here: Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); BufferedImage detectorLaplaciano = DetectorDeBordes.aplicarDetectorLaplaciano(imagenScreen); seleccionarRectangulo(detectorLaplaciano); }//GEN-LAST:event_jMenuItem24ActionPerformed private void jMenuItem25ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem25ActionPerformed // TODO add your handling code here: Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); String valor = JOptionPane.showInputDialog(this, "Valor de sigma", "Definir el valor de sigma", JOptionPane.INFORMATION_MESSAGE); double sSigma = Double.parseDouble(valor); // int longitudMascara = (int) (sSigma * 3); //Imagen imagenOriginal, int sigma, int umbral, int longitudMascara // BufferedImage Laplaciano = DetectorDeBordes.mostrarMascaraLaplacianoDelGaussiano(imagenScreen, sSigma); // Imagen mascaraLaplaciano = new Imagen (Laplaciano, FormatoDeImagen.JPG, "imagen"); int u1 = Umbralizador.generarUmbralizacionOtsu(imagenScreen, Canal.ROJO, false); int u2 = Umbralizador.generarUmbralizacionOtsu(imagenScreen, Canal.AZUL, false); int u3 = Umbralizador.generarUmbralizacionOtsu(imagenScreen, Canal.VERDE, false); int umbral = (u1 + u2 + u3) / 3; Imagen LaplacianoGauss = new Imagen( DetectorDeBordes.aplicarDetectorLaplacianoDelGaussiano(imagenScreen, sSigma, 128), FormatoDeImagen.JPG, "imagen"); Imagen LapGris = new Imagen(p.escalaGrises(LaplacianoGauss.getBufferedImage()), FormatoDeImagen.JPG, "imagen"); seleccionarRectangulo(Umbralizador.umbralizarImagen(LapGris, 100).getBufferedImage()); System.out.println("Detector Laplaciano del Gaussiano OK"); }//GEN-LAST:event_jMenuItem25ActionPerformed private void jMenuItem21ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem21ActionPerformed // TODO add your handling code here: Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); int nuevoUmbral = Umbralizador.encontrarNuevoUmbralGlobal(imagenScreen, 128); JOptionPane.showMessageDialog(this, "Umbral Encontrado: " + nuevoUmbral); Imagen umbralGlobal = Umbralizador.umbralizarImagen(imagenScreen, nuevoUmbral); seleccionarRectangulo(umbralGlobal.getBufferedImage()); }//GEN-LAST:event_jMenuItem21ActionPerformed private void jMenuItem22ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem22ActionPerformed // TODO add your handling code here: Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); int umbralOtsu = Umbralizador.generarUmbralizacionOtsu(imagenScreen, Canal.ROJO, true); Imagen imagenOtsu = Umbralizador.umbralizarImagen(imagenScreen, umbralOtsu); //Imagen imagenOtsu = Umbralizador.generarUmbralizacionColor(imagenScreen); seleccionarRectangulo(imagenOtsu.getBufferedImage()); }//GEN-LAST:event_jMenuItem22ActionPerformed private void jMenuItemLorentzActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemLorentzActionPerformed aplicarAnisotropica(false); }//GEN-LAST:event_jMenuItemLorentzActionPerformed private void jMenuItem20ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem20ActionPerformed // TODO add your handling code here: Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); String valor = JOptionPane.showInputDialog(this, "Valor de sigma", "Definir el valor de sigma", JOptionPane.INFORMATION_MESSAGE); double sSigma = Double.parseDouble(valor); int longitudMascara = (int) (4 + (sSigma * 3)); //Imagen imagenOriginal, int sigma, int umbral, int longitudMascara BufferedImage Laplaciano = DetectorDeBordes.mostrarMascaraLaplacianoDelGaussiano(imagenScreen, sSigma); // BufferedImage LaplacianoGauss = DetectorDeBordes.aplicarDetectorLaplacianoDelGaussiano(imagenScreen, sSigma, 128,longitudMascara ); seleccionarRectangulo(Laplaciano); System.out.println("Mascara Laplaciano del Gaussiano OK"); }//GEN-LAST:event_jMenuItem20ActionPerformed private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu1ActionPerformed }//GEN-LAST:event_jMenu1ActionPerformed private void jMenuItem26ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem26ActionPerformed VentanaSegementarImagen segImagen = new VentanaSegementarImagen(copiarBufferedImage(screen)); JDesktopPane parentPanel = (JDesktopPane) this.getParent(); parentPanel.add(segImagen); segImagen.setVisible(true); }//GEN-LAST:event_jMenuItem26ActionPerformed private void jMenuItem27ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem27ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jMenuItem27ActionPerformed private void jMenuItem29ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem29ActionPerformed // TODO add your handling code here: Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); String u1 = JOptionPane.showInputDialog(this, "Valor de Umbral Bajo (1 a 10)", "Definir el valor del primer umbral", JOptionPane.INFORMATION_MESSAGE); String u2 = JOptionPane.showInputDialog(this, "Valor de Umbral Alto (1 a 10)", "Definir el valor del segundo umbral", JOptionPane.INFORMATION_MESSAGE); float umbral1 = Float.parseFloat(u1); float umbral2 = Float.parseFloat(u2); //ImagePlus canny = DetectorCanny.cannny(cany, umbral1, umbral2); BufferedImage canny = imagenScreen.getBufferedImage(); DetectorDeBordesCanny c = new DetectorDeBordesCanny(umbral1, umbral2); c.setImagenOriginal(canny); c.procesar(); // Imagen canny = DetectorDeBordesDeCanny1.aplicarDetectorDeCanny(imagenScreen, sigma1, sigma2, umbral1, umbral2); seleccionarRectangulo(c.getImagenFinal()); }//GEN-LAST:event_jMenuItem29ActionPerformed private void jMenuItem30ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem30ActionPerformed // TODO add your handling code here: Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); String valor = JOptionPane.showInputDialog(this, "Opciones: \n 1=Detectar Bordes \n 2=Detectar Esquinas", "Detectar bordes o esquinas", JOptionPane.INFORMATION_MESSAGE); int opc = Integer.parseInt(valor); String flag = ""; switch (opc) { case 1: flag = "Bordes"; break; case 2: flag = "Esquinas"; break; } Imagen umbralizada = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); umbralizada.setBufferedImage(DetectorSusan.aplicar(imagenScreen, flag)); if ("Esquinas".equals(flag)) { seleccionarRectangulo( DetectorSusan.superponerAImagenOriginal(umbralizada, imagenScreen).getBufferedImage()); } else { seleccionarRectangulo(umbralizada.getBufferedImage()); } }//GEN-LAST:event_jMenuItem30ActionPerformed private void jMenuItem31ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem31ActionPerformed /* Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); //int umbralOtsu = Umbralizador.generarUmbralizacionOtsu(imagenScreen, Canal.ROJO, true); //Imagen imagenOtsu = Umbralizador.umbralizarImagen(imagenScreen, umbralOtsu); String valorUmbral = JOptionPane.showInputDialog(this, "Valor del umbral", JOptionPane.INFORMATION_MESSAGE); // String t1 = JOptionPane.showInputDialog(this, "Valor de T mnimo", "Definir el valor minimo de ", JOptionPane.INFORMATION_MESSAGE); // String t2 = JOptionPane.showInputDialog(this, "Valor de T mximo", "Definir el valor mximo de ", JOptionPane.INFORMATION_MESSAGE); //String r1 = JOptionPane.showInputDialog(this, "Valor de R mnimo", "Definir el valor minimo de ?", JOptionPane.INFORMATION_MESSAGE); //String r2 = JOptionPane.showInputDialog(this, "Valor de R mximo", "Definir el valor mximo de ?", JOptionPane.INFORMATION_MESSAGE); //String dis = JOptionPane.showInputDialog(this, "Cantidad de elementos para discretizar intervalos", "Definir la cantidad de elementos en los que se discretizan estos intervalos", JOptionPane.INFORMATION_MESSAGE); //int tMin = Integer.valueOf(t1); //int tMax = Integer.valueOf(t2); //int rMin = Integer.valueOf(r1); //int rMax = Integer.valueOf(r2); int r1 = imagenScreen.getBufferedImage().getHeight(); int r2 = imagenScreen.getBufferedImage().getWidth(); int D = Math.max(r1, r2); int D1 = (int) (-1 * Math.sqrt(2 * D)); int D2 = (int) (Math.sqrt(2 * D)); // int dT = Integer.valueOf(dis); System.out.println(D1 + " - " + D2); // System.out.println(dT); // TransformadaDeHough.aplicarTransformadaDeHough(imagenScreen, -90, 90, dT, D1, D2, dT, Integer.parseInt(valorUmbral)); // Imagen rectasH = TransformadaDeHough.houghRectas(imagenOtsu, umbralOtsu); HoughTransform h = new HoughTransform(imagenScreen.getBufferedImage().getWidth(), imagenScreen.getBufferedImage().getHeight()); seleccionarRectangulo(h.getHoughArrayImage());*/ String um = JOptionPane.showInputDialog(this, "Valor Del Umbral", "Valor Del Umbra", JOptionPane.INFORMATION_MESSAGE); String t1 = JOptionPane.showInputDialog(this, "Valor de mnimo", "Definir el valor minimo de ", JOptionPane.INFORMATION_MESSAGE); String t2 = JOptionPane.showInputDialog(this, "Valor de mximo", "Definir el valor mximo de ", JOptionPane.INFORMATION_MESSAGE); String r1 = JOptionPane.showInputDialog(this, "Valor de ? mnimo", "Definir el valor minimo de ?", JOptionPane.INFORMATION_MESSAGE); String r2 = JOptionPane.showInputDialog(this, "Valor de ? mximo", "Definir el valor mximo de ?", JOptionPane.INFORMATION_MESSAGE); String disTheta = JOptionPane.showInputDialog(this, "Cantidad de elementos para discretizar intervalos ", "Discretizar en intervalos", JOptionPane.INFORMATION_MESSAGE); String disThetaRo = JOptionPane.showInputDialog(this, "Cantidad de elementos para discretizar intervalos ?", "Discretizar ? en intervalos", JOptionPane.INFORMATION_MESSAGE); int tMin = Integer.valueOf(t1); int tMax = Integer.valueOf(t2); int rMin = Integer.valueOf(r1); int rMax = Integer.valueOf(r2); int umbral = Integer.valueOf(um); int disTInt = Integer.valueOf(disTheta); int disRInt = Integer.valueOf(disThetaRo); TranformadaDeHoughRectas.aplicarTranformadaDeHough(screen, tMin, tMax, disTInt, rMin, rMax, disRInt, umbral); }//GEN-LAST:event_jMenuItem31ActionPerformed private void jMenuItem33ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem33ActionPerformed // TODO add your handling code here: Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); Imagen esquinasHarris = DetectorDeHarris.detectarEsquinas(imagenScreen); seleccionarRectangulo(esquinasHarris.getBufferedImage()); }//GEN-LAST:event_jMenuItem33ActionPerformed private void jMenuItem34ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem34ActionPerformed File elegida = p.abrirFile(); File fileScreen = new File("fileScreen.jpg"); try { ImageIO.write(screen, "jpg", fileScreen); Sift.aplicarMetodoSift(fileScreen, elegida, jMenuItemIsRobusto.isSelected()); } catch (IOException ex) { Logger.getLogger(Editar.class.getName()).log(Level.SEVERE, null, ex); } catch (Exception ex) { Logger.getLogger(Editar.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_jMenuItem34ActionPerformed private void jMenuItemIsRobustoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemIsRobustoActionPerformed }//GEN-LAST:event_jMenuItemIsRobustoActionPerformed private void jMenuItem32ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem32ActionPerformed // TODO add your handling code here: System.load("C:\\Users\\javi_\\Desktop\\downloades\\opencv\\opencv\\build\\java\\x64\\opencv_java2413.dll"); String umbral = JOptionPane.showInputDialog(this, "Umbral: ", "Valor del Umbral", JOptionPane.INFORMATION_MESSAGE); String radmin = JOptionPane.showInputDialog(this, "Radio Minimo: ", "Valor minimo del radio", JOptionPane.INFORMATION_MESSAGE); String radmax = JOptionPane.showInputDialog(this, "Radio Maximo", "Valor de Maximo del radio", JOptionPane.INFORMATION_MESSAGE); int umbralInt = Integer.valueOf(umbral); int radminInt = Integer.valueOf(radmin); int radmaxInt = Integer.valueOf(radmax); BufferedImage res = HoughCirculos.implementarCiculos(screen, umbralInt, radminInt, radmaxInt); seleccionarRectangulo(res); //Highgui.imwrite("asdas.jpg", destination); }//GEN-LAST:event_jMenuItem32ActionPerformed private void circuloMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_circuloMenuItemActionPerformed // TODO add your handling code here: seleccionarRectangulo(Graficador.crearImagenConCirculoEnElMedio(200, 200, 80)); }//GEN-LAST:event_circuloMenuItemActionPerformed private void cuadradoMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cuadradoMenuItemActionPerformed // TODO add your handling code here: seleccionarRectangulo(Graficador.crearImagenConCuadradoEnElCentro(200, 200, 160)); }//GEN-LAST:event_cuadradoMenuItemActionPerformed private void grisesMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_grisesMenuItemActionPerformed // TODO add your handling code here: seleccionarRectangulo(Graficador.crearImagenConDegradeDeGrises(200, 200)); }//GEN-LAST:event_grisesMenuItemActionPerformed private void coloresMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_coloresMenuItemActionPerformed seleccionarRectangulo(Graficador.crearImagenConDegradeColor(200, 200)); // TODO add your handling code here: }//GEN-LAST:event_coloresMenuItemActionPerformed private void jMenuItem35ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem35ActionPerformed Imagen imagenScreen = new Imagen(screen, FormatoDeImagen.JPG, "imagen"); Imagen imagenUmbralColor = Umbralizador.generarUmbralizacionColor(imagenScreen); seleccionarRectangulo(imagenUmbralColor.getBufferedImage()); }//GEN-LAST:event_jMenuItem35ActionPerformed public static BufferedImage matToBufferedImage(Mat matrix) { BufferedImage bimg = new BufferedImage(1, 1, 1); if (matrix != null) { int cols = matrix.cols(); int rows = matrix.rows(); int elemSize = (int) matrix.elemSize(); byte[] data = new byte[cols * rows * elemSize]; int type; matrix.get(0, 0, data); switch (matrix.channels()) { case 1: type = BufferedImage.TYPE_BYTE_GRAY; break; case 3: type = BufferedImage.TYPE_3BYTE_BGR; // bgr to rgb byte b; for (int i = 0; i < data.length; i = i + 3) { b = data[i]; data[i] = data[i + 2]; data[i + 2] = b; } break; default: return null; } // Reuse existing BufferedImage if possible if (bimg == null || bimg.getWidth() != cols || bimg.getHeight() != rows || bimg.getType() != type) { bimg = new BufferedImage(cols, rows, type); } bimg.getRaster().setDataElements(0, 0, cols, rows, data); } else { // mat was null bimg = null; } return bimg; } private BufferedImage copiarBufferedImage(BufferedImage original) { ColorModel cm = original.getColorModel(); boolean isAlphaPremultiplied = cm.isAlphaPremultiplied(); WritableRaster raster = original.copyData(null); BufferedImage copy = new BufferedImage(cm, raster, isAlphaPremultiplied, null); return copy; } protected static final String EXTENSION = ".jpg"; protected static final String FORMAT_NAME = "jpg"; protected static final LayoutFileFilter SAVE_AS_IMAGE = new LayoutFileFilter("PNG Image Format", EXTENSION, true); protected int chooseSaveFile(BufferedImage image) { JFileChooser fileChooser = new JFileChooser(); ExtensionFileFilter pFilter = new ExtensionFileFilter(SAVE_AS_IMAGE); fileChooser.setFileFilter(pFilter); int status = fileChooser.showSaveDialog(this); if (status == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); try { String fileName = selectedFile.getCanonicalPath(); if (!fileName.endsWith(EXTENSION)) { selectedFile = new File(fileName + EXTENSION); } ImageIO.write(image, FORMAT_NAME, selectedFile); } catch (IOException e) { e.printStackTrace(); } } return status; } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JMenuItem Personalizado; private javax.swing.JButton btnCambierRgb; private javax.swing.JMenuItem circuloMenuItem; private javax.swing.JMenuItem coloresMenuItem; private javax.swing.JMenu crearMenuItem; private javax.swing.JMenuItem cuadradoMenuItem; private javax.swing.JMenuItem grisesMenuItem; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JMenu jMenu1; private javax.swing.JMenu jMenu2; private javax.swing.JMenu jMenu3; private javax.swing.JMenu jMenu4; private javax.swing.JMenu jMenu5; private javax.swing.JMenu jMenu6; private javax.swing.JMenu jMenu7; private javax.swing.JMenu jMenuAnisotropica; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JMenu jMenuDetectoresDeBorde; private javax.swing.JMenu jMenuDireccionales; private javax.swing.JMenuItem jMenuItem1; private javax.swing.JMenuItem jMenuItem10; private javax.swing.JMenuItem jMenuItem11; private javax.swing.JMenuItem jMenuItem12; private javax.swing.JMenuItem jMenuItem13; private javax.swing.JMenuItem jMenuItem14; private javax.swing.JMenuItem jMenuItem15; private javax.swing.JMenuItem jMenuItem16; private javax.swing.JMenuItem jMenuItem17; private javax.swing.JMenuItem jMenuItem18; private javax.swing.JMenuItem jMenuItem19; private javax.swing.JMenuItem jMenuItem2; private javax.swing.JMenuItem jMenuItem20; private javax.swing.JMenuItem jMenuItem21; private javax.swing.JMenuItem jMenuItem22; private javax.swing.JMenuItem jMenuItem23; private javax.swing.JMenuItem jMenuItem24; private javax.swing.JMenuItem jMenuItem25; private javax.swing.JMenuItem jMenuItem26; private javax.swing.JMenuItem jMenuItem27; private javax.swing.JMenuItem jMenuItem29; private javax.swing.JMenuItem jMenuItem3; private javax.swing.JMenuItem jMenuItem30; private javax.swing.JMenuItem jMenuItem31; private javax.swing.JMenuItem jMenuItem32; private javax.swing.JMenuItem jMenuItem33; private javax.swing.JMenuItem jMenuItem34; private javax.swing.JMenuItem jMenuItem35; private javax.swing.JMenuItem jMenuItem4; private javax.swing.JMenuItem jMenuItem5; private javax.swing.JMenuItem jMenuItem6; private javax.swing.JMenuItem jMenuItem7; private javax.swing.JMenuItem jMenuItem8; private javax.swing.JMenuItem jMenuItem9; private javax.swing.JMenuItem jMenuItemHistograma; private javax.swing.JCheckBoxMenuItem jMenuItemIsRobusto; private javax.swing.JMenuItem jMenuItemLeclerc; private javax.swing.JMenuItem jMenuItemLorentz; private javax.swing.JMenuItem jMenuItemPrewitt; private javax.swing.JMenuItem jMenuItemRestaurar; private javax.swing.JMenuItem jMenuItemSalYPimienta; private javax.swing.JMenuItem jMenuKirsh; private javax.swing.JMenu jMenuLaplaciano; private javax.swing.JMenu jMenuPrewitt; private javax.swing.JMenu jMenuSobel; private javax.swing.JMenuItem jMenuSobelDireccional; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel5; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JLabel labelDmiencion; private javax.swing.JLabel labelProm; private javax.swing.JLabel labelPromB; private javax.swing.JLabel labelPromG; private javax.swing.JLabel labelPromR; private javax.swing.JLabel labelPuntoActual; private javax.swing.JMenu menuArchivo; private javax.swing.JMenuItem menuBordes; private javax.swing.JMenuItem menuDinamico; private javax.swing.JMenuItem menuEscalar; private javax.swing.JMenu menuFiltros; private javax.swing.JMenuItem menuGauss; private javax.swing.JMenu menuHerramientas; private javax.swing.JMenuItem menuMedia; private javax.swing.JMenuItem menuMediana; private javax.swing.JMenuItem menuNegativo; private javax.swing.JMenu menuOperaciones; private javax.swing.JMenuItem menuPotencia; private javax.swing.JMenuItem menuProducto; private javax.swing.JMenuItem menuResta; private javax.swing.JMenu menuRuido; private javax.swing.JMenuItem menuSuma; private javax.swing.JLabel screenLabel; private javax.swing.JTextField txtBuscarX; private javax.swing.JTextField txtBuscarY; private javax.swing.JTextField txtValorB; private javax.swing.JTextField txtValorG; private javax.swing.JTextField txtValorR; // End of variables declaration//GEN-END:variables }