IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ImageJ Java Discussion :

Automatisation de soustractions d'images


Sujet :

ImageJ Java

  1. #1
    Nouveau Candidat au Club
    Profil pro
    Inscrit en
    Avril 2012
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2012
    Messages : 5
    Points : 1
    Points
    1
    Par défaut Automatisation de soustractions d'images
    Bonjour,
    Je vous écris car je suis un peu en galère avec les fonctions macros/plugins de ImageJ.

    En effet, je voudrais soustraire une image (Background) avec une autre image (via la fonction ImageCalculator) et faire ceci pour toutes les images qui se trouvent dans un répertoire donné. Je n'arrive pas à trouver les commandes pour automatiser tout ceci, je suis tombé sur un topic où une personne avait les mêmes intentions et qui a donné ses lignes de commandes (voir ci-dessous) mais je n'arrive pas à le faire marcher ...


    http://www.developpez.net/forums/d10...ge-calculator/

    Si quelqu'un pouvait m'aider pour écrire les lignes de commandes ça serait sympa

    Merci d'avance pour vos réponses !

  2. #2
    Membre régulier
    Homme Profil pro
    Thésard BioInformatique
    Inscrit en
    Décembre 2008
    Messages
    97
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Thésard BioInformatique

    Informations forums :
    Inscription : Décembre 2008
    Messages : 97
    Points : 104
    Points
    104
    Par défaut
    Salut,

    Si ton image "background" est toujours la même, je te propose le code suivant :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    import ij.IJ;
    import ij.ImagePlus;
    import ij.plugin.ImageCalculator;
    import ij.plugin.PlugIn;
    import java.io.File;
    import javax.swing.JFileChooser;
    import javax.swing.JFrame;
     
     
    public class TESTPlugin_ implements PlugIn{
     
    	public void run(String arg) {
    		ImageCalculator ic = new ImageCalculator();
    		String directory = directoryChooser();
    		String nameimageref = fileChooser();
    		File[] listeFichiers; 		
    		File repertoire = new File(directory); 		
    		listeFichiers = repertoire.listFiles();
     
    		ImagePlus impbackground = new ImagePlus(nameimageref);
    		ImagePlus imp = new ImagePlus();
    		ImagePlus impResult = new ImagePlus();
    		for (File imgname : listeFichiers) {
    			imp = new ImagePlus(imgname.getPath());
    			impResult = ic.run("Subtract create",imp ,impbackground);
    			impResult.setTitle("Result_"+imp.getTitle());
    			saveImg(impResult, directory);
    		}
    		IJ.showStatus("Done...");
    	}
     
    	public void saveImg(ImagePlus imp, String path) {
    		String fname = path +"\\" +imp.getTitle();
    		IJ.save(imp, fname);
        }
     
    	public String directoryChooser()
    	{
    		JFileChooser choix = new JFileChooser();
    		choix.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    		int retour = choix.showOpenDialog(new JFrame());
    		if(retour == JFileChooser.APPROVE_OPTION) {
    			return choix.getSelectedFile().getAbsolutePath();
    		} else {
    			return "Le dossier n'a pas été choisi!"; }
    	}
     
    	public String fileChooser()
    	{
    		JFileChooser choix = new JFileChooser();
    		int retour = choix.showOpenDialog(new JFrame());
    		if(retour == JFileChooser.APPROVE_OPTION) {
    			return choix.getSelectedFile().getAbsolutePath();
    		} else {
    			return "L'image n'a pas étée choisie !"; }
    	}
    }
    Tu trouveras ici (http://imagejdocu.tudor.lu/doku.php?..._eclipse_howto) comment faire le plugin sous eclipse pour imageJ.


    Le plugin est basique, il te demande le dossier à traiter puis l'image background et il enregistre les résultats dans le dossier traiter.

    Je pense qu'avec cette base tu pourras déjà faire pas mal de chose.

  3. #3
    Nouveau Candidat au Club
    Profil pro
    Inscrit en
    Avril 2012
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2012
    Messages : 5
    Points : 1
    Points
    1
    Par défaut
    Ouki , je te remercie, je vais aller essayer cela et je te tiens au courant !

  4. #4
    Nouveau Candidat au Club
    Profil pro
    Inscrit en
    Avril 2012
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2012
    Messages : 5
    Points : 1
    Points
    1
    Par défaut
    bon j'ai suivi le tutorial, mais j'arrive à un problème. Après avoir choisi le dossier et l'image (background) j'ai un message d'erreur


    java.lang.NullPointerException
    at ij.plugin.ImageCalculator.createNewImage(ImageCalculator.java:253)
    at ij.plugin.ImageCalculator.doOperation(ImageCalculator.java:226)
    at ij.plugin.ImageCalculator.calculate(ImageCalculator.java:146)
    at ij.plugin.ImageCalculator.run(ImageCalculator.java:99)
    at TESTPlugin_.run(TESTPlugin_.java:25)
    at ij.IJ.runUserPlugIn(IJ.java:183)
    at ij.IJ.runPlugIn(IJ.java:150)
    at ij.Executer.runCommand(Executer.java:127)
    at ij.Executer.run(Executer.java:64)
    at java.lang.Thread.run(Unknown Source)


    Je ne sais pas d'où le problème vient maintenant

  5. #5
    Nouveau Candidat au Club
    Profil pro
    Inscrit en
    Avril 2012
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2012
    Messages : 5
    Points : 1
    Points
    1
    Par défaut
    Rectification: Le plugin a l'air de marcher , je peux choisir le dossier où se trouve les images, je peux choisir mon background, par contre je me retrouve à la fin avec uniquement des images noires ... Je vais essayer de voir au niveau des lignes de commandes que tu m'as donné ... si tu as une suggestion je suis preneur

  6. #6
    Nouveau Candidat au Club
    Profil pro
    Inscrit en
    Avril 2012
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2012
    Messages : 5
    Points : 1
    Points
    1
    Par défaut
    J'ai trouvé la solution :

    il fallait changer cette ligne
    impResult = ic.run("Subtract create",imp ,impbackground);

    par

    impResult = ic.run("Subtract create",impbackground ,imp);


    Merci pour les lignes de commandes, ça va me faciliter la vie!!!
    Bonne continuation à toi et merci encore !!

  7. #7
    Membre régulier
    Homme Profil pro
    Thésard BioInformatique
    Inscrit en
    Décembre 2008
    Messages
    97
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Thésard BioInformatique

    Informations forums :
    Inscription : Décembre 2008
    Messages : 97
    Points : 104
    Points
    104
    Par défaut
    Ha oui, désolé. J'ai fait ça à la va vite, j'ai pas regardé l'ordre de la soustraction!

    Bonne continuation

Discussions similaires

  1. Soustraction d'images successives sur une vidéo
    Par kmedghaith dans le forum Qt Quick
    Réponses: 2
    Dernier message: 11/02/2014, 22h35
  2. Automatiser le centrage d'images (500)
    Par ekevin dans le forum Imagerie
    Réponses: 0
    Dernier message: 09/04/2010, 11h32
  3. Soustraction d'image à une autre image
    Par meyerph dans le forum ImageJ
    Réponses: 4
    Dernier message: 29/06/2009, 09h57
  4. Automatiser impression avec Document Image Writer
    Par Crystal73 dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 22/11/2007, 17h12
  5. Fusion et soustraction des images
    Par anisj1m dans le forum Images
    Réponses: 2
    Dernier message: 11/08/2006, 10h33

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo