Ir ao conteúdo
  • Cadastre-se

Detectos de bordas Sobel


Ariane Alvarez

Posts recomendados

Estou fazendo um trabalho no Netbeans utilizando visual e não consigo fazer a parte do código de detecção de bordas sobel, se alguém souber ajudar.

Código:


String caminhoArquivo;
public NewLayout() {
initComponents();
}
private void initComponents() {
receber_caminho = new javax.swing.JTextField();
Visualiar_Imagens = new javax.swing.JTabbedPane();
Imagem_Original = new javax.swing.JTabbedPane();
Original = new javax.swing.JLabel();
Modificada = new javax.swing.JLabel();
Menu = new javax.swing.JMenuBar();
Opções = new javax.swing.JMenu();
Open = new javax.swing.JMenuItem();
Exit = new javax.swing.JMenuItem();
Filtro = new javax.swing.JMenu();
Filtros = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Detector De Bordas - Sobel");
receber_caminho.setEditable(false);
receber_caminho.setBackground(new java.awt.Color(153, 180, 209));
receber_caminho.setName("");
receber_caminho.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
receber_caminhoActionPerformed(evt);
}
}); Visualiar_Imagens.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
Visualiar_Imagens.setEnabled(false);
Original.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
Imagem_Original.addTab("Original", Original);
Modificada.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
Imagem_Original.addTab("Modificada", Modificada);
Visualiar_Imagens.addTab("Visualizado de Imagem", Imagem_Original);
Opções.setText("File");
Open.setText("Abrir");
Open.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
OpenActionPerformed(evt);
}
});
Opções.add(Open);
Exit.setText("Sair");
Exit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ExitActionPerformed(evt);
}
});
Opções.add(Exit);
Menu.add(Opções);
Filtro.setText("Filtros");
Filtros.setText("Detecção de Borda - Sobel");
Filtros.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
FiltrosActionPerformed(evt);
}
});
Filtro.add(Filtros);
Menu.add(Filtro);
setJMenuBar(Menu);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(receber_caminho)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(Visualiar_Imagens, javax.swing.GroupLayout.PREFERRED_SIZE, 490, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap()) );
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(receber_caminho, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Visualiar_Imagens, javax.swing.GroupLayout.DEFAULT_SIZE, 557, Short.MAX_VALUE)
.addGap(21, 21, 21)) );
pack();
}
private void receber_caminhoActionPerformed(java.awt.event.ActionEvent evt) {
}
private void OpenActionPerformed(java.awt.event.ActionEvent evt) {
JFileChooser fc = new JFileChooser();
fc.setFileFilter(new FileNameExtensionFilter("JPG, GIF, PNG E BMP", "jpg", "gif", "png","bmp"));
fc.setDialogTitle("Escolha a Imagem");
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
int retorno = fc.showOpenDialog(null);
if(retorno == JFileChooser.APPROVE_OPTION){
File arquivo = fc.getSelectedFile();
String IMC = arquivo.getPath();
ImageIcon imagem = new ImageIcon(IMC);
Image img = imagem.getImage();
Original.setIcon(new ImageIcon (img));
receber_caminho.setText(IMC);
caminhoArquivo = fc.getSelectedFile().getPath()
}else{
JOptionPane.showMessageDialog(null,"Operação Cancelada Pelo Usuário ...");
}
}
private void ExitActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
private void FiltrosActionPerformed(java.awt.event.ActionEvent evt) {
try {
BufferedImage img = ImageIO.read(new File(caminhoArquivo));

/*CÓDIGO FILTRO*/

}
Modificada.setIcon(new ImageIcon(metade));
} catch (IOException ex) {
Logger.getLogger(NewLayout.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(NewLayout.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) { java.util.logging.Logger.getLogger(NewLayout.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(NewLayout.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(NewLayout.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewLayout().setVisible(true);
}
});
}
public class NewLayout extends javax.swing.JFrame {

Obrigada!!

Link para o comentário
Compartilhar em outros sites

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

 

GRÁTIS: ebook Redes Wi-Fi – 2ª Edição

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!