Purify_ plugin

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

Purify_ plugin

Michael Doube
Hi all

I have reworked Fabrice P. Cordelières' 3D Object Counter to remove all
but the largest particle from a binary 3D stack, preparing the stack for
connectivity analysis.

Since the object counting algorithm is recursive and my group uses large
(up to 2048 x 2048 x 2048 pixel) stacks, it can be very slow, so I have
adapted the algorithm for multiple CPUs.  Since this is my first go at
writing a multithreaded plugin, I'm sure it is not ideal, but it seems
to work for me, and is quite a lot faster than the single-threaded
alternative.

If you would like to check it out, it's here:

http://doube.org/plugins.html#purify

I'm working on improving my coding style, so any suggestions you have
are appreciated.

Cheers,

Mike
Reply | Threaded
Open this post in threaded view
|

Re: Purify_ plugin

Albert Cardona
Michael Doube wrote:
> http://doube.org/plugins.html#purify
>
> I'm working on improving my coding style, so any suggestions you have
> are appreciated.


For multithreading, I discovered about a year ago the Executors,
ExecutorService, Future, and Callable classes that make multithreading
dead-easy.

For example:

ExecutorService exec =
Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());

class DoSomething implements Callable<ImagePlus> {
    public ImagePlus call() {
        // generate an image
        ImagePlus imp = new ImagePlus("that", new FloatProcessor(500, 500));
        return imp;
    }
}


Future<ImagePlus> fu = exec.submit(new DoSomething());

// blocks until it's done:
ImagePlus result = fu.get();

result.show();


// when done:
exec.shutdown();

It's very convenient to operate over very large collections of objects
or operations.

Albert

--
Albert Cardona
http://albert.rierol.net