Detection de contour d'image avec java

cs_mmlm Messages postés 5 Date d'inscription vendredi 25 novembre 2011 Statut Membre Dernière intervention 14 décembre 2011 - 10 déc. 2011 à 10:44
cs_mmlm Messages postés 5 Date d'inscription vendredi 25 novembre 2011 Statut Membre Dernière intervention 14 décembre 2011 - 14 déc. 2011 à 14:40
Je souhaite afficher le contour d'une images avec une application java. Sur le site je n'ai trouvé que des exemples avec c++ or je dois utiliser JAVA.j'ai essayer de le convertir mais je n'arrive pas.
merci

6 réponses

Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 111
10 déc. 2011 à 11:22
Salut,

Ok, c'est pas compliqué de donner quelques info sur ce que tu sais ou pas faire (ça aide à pas te/nous faire perdre du temps)...
Cela dit tu n'as pas cherché bien loin... ou tu as bien mal chercheé... en tapant "java detection de contour" sur google je tombe en premier lien sur "http://www.developpez.net/forums/d298554/java/interfaces-graphiques-java/graphisme/2d/detection-contour/... en bas du post tu as le code java...





------------------------------------
"On n'est pas au resto : ici on ne fait pas dans les plats tout cuits ..."

OoWORAoO
1
Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 111
10 déc. 2011 à 10:53
Salut,

Tu n'y arrives pas à quel niveau ? tu déjà fais quoi ? etc... ?
N’espère pas lâcher une simple 'je n'y arrive pas" et obtenir du code... il nous faut de la matière.




------------------------------------
"On n'est pas au resto : ici on ne fait pas dans les plats tout cuits ..."

OoWORAoO
0
cs_mmlm Messages postés 5 Date d'inscription vendredi 25 novembre 2011 Statut Membre Dernière intervention 14 décembre 2011
10 déc. 2011 à 11:02
je ne sais pas quel sont les bibliothèque nécessaire et bien sur les instruction qui concerne l'action de bouton qui effectue la détection du contour .
0
Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 111
10 déc. 2011 à 11:05
Donc tu ne connais pas les bases en java, ni même celles pour faire des ihm et encore moi pour la manipulation d'image et tu souhaites faire ce genre d'application pour commencer ?




------------------------------------
"On n'est pas au resto : ici on ne fait pas dans les plats tout cuits ..."

OoWORAoO
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_mmlm Messages postés 5 Date d'inscription vendredi 25 novembre 2011 Statut Membre Dernière intervention 14 décembre 2011
10 déc. 2011 à 11:12
Mais non!!!!!!!!!!!!
je réalise des interface graphique qui permet de parcourir une image puis la redimensionne et effectue aussi des rotation mais c'est juste les instruction de détection de contour que j'ai besoin pour compléter mon projet
0
cs_mmlm Messages postés 5 Date d'inscription vendredi 25 novembre 2011 Statut Membre Dernière intervention 14 décembre 2011
14 déc. 2011 à 14:40
Bonjour
je suis en cour de réaliser un programme java qui détecte le contour d'une image mais je n'arrive pas ,je trouve dans le site une méthode qui nécessite
un bafferedImage or je besion d'une methode avec plannarImage ou bien un bout de code qui permet de forsage de type plannar image vers bufferd image
voici le code d'action performed de boutton de l'inerface:

import java.awt.image.BufferedImage;
import java.awt.image.ConvolveOp;
import java.awt.image.Kernel;
import java.awt.image.renderable.ParameterBlock;
import javax.media.jai.InterpolationBilinear;
import javax.media.jai.JAI;
import javax.media.jai.PlanarImage;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/*
* FENETRE.java
*
* Created on 13 déc. 2011, 19:34:42
*/

/**
*
* @author Administrateur
*/
public class FENETRE extends javax.swing.JFrame {

/** Creates new form FENETRE */
public FENETRE() {
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">
private void initComponents() {

jButton1 = new javax.swing.JButton();
url = new java.awt.TextField();
img = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jButton1.setBackground(new java.awt.Color(102, 102, 255));
jButton1.setFont(new java.awt.Font("SansSerif", 1, 14));
jButton1.setText("Parcourir image");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

img.setText("jLabel1");

jButton2.setBackground(new java.awt.Color(102, 102, 255));
jButton2.setFont(new java.awt.Font("Serif", 1, 14));
jButton2.setText("Transformation");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jLabel1.setText("jLabel1");

org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(93, 93, 93)
.add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 147, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(layout.createSequentialGroup()
.addContainerGap()
.add(img, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 240, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(90, 90, 90)
.add(url, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 436, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(layout.createSequentialGroup()
.add(270, 270, 270)
.add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 262, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.add(308, 308, 308))
.add(layout.createSequentialGroup()
.add(263, 263, 263)
.add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 155, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(85, 85, 85)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(url, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 33, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 46, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(25, 25, 25)
.add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 48, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(23, 23, 23)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(img, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 274, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 261, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addContainerGap(45, Short.MAX_VALUE))
);

pack();
}// </editor-fold>

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
JFileChooser jf = new JFileChooser ();
jf.showOpenDialog(null);
url.setText(jf.getSelectedFile().getPath());
PlanarImage p=JAI.create("fileload",url.getText());
img.setIcon(new ImageIcon(p.getAsBufferedImage()));

}
public static BufferedImage contour(BufferedImage img) {

BufferedImage dst = new BufferedImage(img.getWidth(), img.getHeight(),
BufferedImage.TYPE_INT_ARGB);
// Definition du masque de convolution utilisé pour la détéction des contours de
// l'image
float[] mask = { -0.1F, -0.1F, -0.1F, -0.1F, 0.8F, -0.1F, -0.1F, -0.1F, -0.1F};
Kernel kernel = new Kernel(3, 3, mask);
// On creer notre outils de convolution
ConvolveOp convo = new ConvolveOp(kernel);
// On effectue la convolution
convo.filter(img, dst);
// On retourne l'image convoluée
return dst;
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
PlanarImage u=JAI.create("fileload",url.getText());
BufferedImage u = FENETRE.contour(img);


dst.setIcon(new ImageIcon(u.getAsBufferedImage()));;
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new FENETRE().setVisible(true);
}
});
}

// Variables declaration - do not modify
private javax.swing.JLabel img;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private java.awt.TextField url;
// End of variables declaration

}
0
Rejoignez-nous