Reusing Make Binary and Skeletonize methods
Posted by hector.longarte on Dec 12, 2008; 2:11pm
URL: http://imagej.273.s1.nabble.com/Reusing-Make-Binary-and-Skeletonize-methods-tp3694262.html
Hello Imagers,
I need help with this: I need to use the plugins of imageJ in my
application with the command for Make binary:
*IJ.runPlugin(imp,"ij.plugin.Thresholder", "Make Binary");*
And skeletize it...
*IJ.runPlugIn(imp,"ij.plugin.filter.Binary", "Skeletonize"); *
But the image I get appears noised all times,may be I am missing some
parameter?
I am copying here the classes I am writting ..
If someone can help me I will send the image of the check to personal mail
because this list does not accept attached files ...
Thank you very much if someone may help me..
*Class for the preprocessing:*
package com;
import ij.IJ;
import ij.ImagePlus;
import java.awt.image.BufferedImage;
public class Preprocessing {
// Binarizacion...
public BufferedImage umbralizarFirma(BufferedImage firma) {
ImagePlus imp;
imp = new ImagePlus("firmaOriginal", firma);
IJ.runPlugIn(imp,"ij.plugin.filter.Binary", "Make Binary");
BufferedImage bf = (BufferedImage) imp.getImage();
return bf;
}
// Skeletonize...
public BufferedImage skeletonFirma(BufferedImage firma) {
ImagePlus imp;
imp = new ImagePlus("firmaOriginal", firma);
IJ.runPlugIn(imp,"ij.plugin.filter.Binary", "Skeletonize");
BufferedImage bf = (BufferedImage) imp.getImage();
return bf;
}
}
------------------------------
----------------------------------------------------------
*Main class:*
package com;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import com.Preprocessing;
public class Director {
private BufferedImage imagen;
//Constructors...
public Director(String imagen) throws Exception {
this.imagen = ImageIO.read(new File(imagen));
}
public Director() { }
// Write image to disk...
public void guardarImagen(String nombreResultado) {
try {
ImageIO.write(imagen, "jpg", new File(nombreResultado));
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) throws Exception {
// Load the check and cut the signature...
Director imagenCheque = new Director("c:/chequeAnverso.bmp");
Director imagenFirma = new Director();
System.out.println("*** Recortando desde el pixel 370,138 ...");
imagenFirma.imagen = imagenCheque.imagen.getSubimage(370, 138,322,
135);
imagenFirma.guardarImagen("c:/firma5.bmp");
// Binarize the signature...
Preprocessing binarize = new Preprocessing();
imagenFirma.imagen = binarize.umbralizarFirma(imagenFirma.imagen);
imagenFirma.guardarImagen("c:/firmaBinarizada5.bmp");
System.out.println("*** Firma binarizada...");
// Skeletonize the signature...
imagenFirma.imagen = binarize.skeletonFirma(imagenFirma.imagen);
imagenFirma.guardarImagen("c:/firmaSkeleton5.bmp");
System.out.println("*** Firma skeletionized...");
}
}