Login  Register

Re: Skeletonize BufferedImage with imagej

Posted by Albert Cardona on Dec 06, 2007; 1:58am
URL: http://imagej.273.s1.nabble.com/Skeletonize-BufferedImage-with-imagej-tp3697853p3697856.html

Indara,

As it says here:
 
http://rsb.info.nih.gov/ij/developer/api/ij/process/ByteProcessor.html#skeletonize()

the skeletonize method returns void, not an ImageProcessor.

Also, each ImagePlus has a getProcessor() method, no need to recreate it
every time from the awt.Image generated, in the first place, from that
very same processor.

Thus:


Opener imageOpener = new Opener();
Image img, imgresult;
ImagePlus imp = imageOpener.openImage("image.jpg");
       
imp.setProcessor(imp.getTitle(),imp.getProcessor().convertToByte(true));

ByteProcessor byteprocessor = (ByteProcessor)imp.getProcessor();
byteprocessor.skeletonize();


// the skeletonized image (should be updated)
imgresult = imp.getImage();

// The method above returns you a cached image
// which is usually updated after editing the source processor,
// but not always.
// You can force it to update with:

imp.updateAndDraw();
imgresult = imp.getImage();

// Or just get a new, fresh image directly:
imgresult = byteprocessor.createImage();



--
Albert Cardona
http://www.mcdb.ucla.edu/Research/Hartenstein/acardona