Skeletonize BufferedImage with imagej

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Skeletonize BufferedImage with imagej

Indara
Hello,

I am trying to skeletonize a bufferedimage with imageJ and save the result of skeleton in buffered image.
I am confuse on how to do it. Can anyone please help me, and give example of the sourcecode.

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Skeletonize BufferedImage with imagej

Albert Cardona
> I am trying to skeletonize a bufferedimage with imageJ and save the result
> of skeleton in buffered image.
> I am confuse on how to do it. Can anyone please help me, and give example of
> the sourcecode.
>  


Indara,

Show some working code, and I'll help you fix it.
It's not hard. Just have a look at the API, classes ImagePlus and
ByteProcessor.

http://rsb.info.nih.gov/ij/developer/api/index.html


Albert

--
Albert Cardona
http://www.mcdb.ucla.edu/Research/Hartenstein/acardona
Reply | Threaded
Open this post in threaded view
|

Re: Skeletonize BufferedImage with imagej

Indara
This is the code..

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

Please take a look at the code Thanks.


Albert Cardona wrote
> I am trying to skeletonize a bufferedimage with imageJ and save the result
> of skeleton in buffered image.
> I am confuse on how to do it. Can anyone please help me, and give example of
> the sourcecode.
>  


Indara,

Show some working code, and I'll help you fix it.
It's not hard. Just have a look at the API, classes ImagePlus and
ByteProcessor.

http://rsb.info.nih.gov/ij/developer/api/index.html


Albert

--
Albert Cardona
http://www.mcdb.ucla.edu/Research/Hartenstein/acardona
Reply | Threaded
Open this post in threaded view
|

Re: Skeletonize BufferedImage with imagej

Albert Cardona
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
Reply | Threaded
Open this post in threaded view
|

Re: Skeletonize BufferedImage with imagej

Indara
Thanks a lot for your suggestion. I will try to implement that.


Albert Cardona wrote
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