Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » ImageJ Flood Fill(ImageJ Flood Fill)
ImageJ Flood Fill [message #699467] Thu, 21 July 2011 15:23 Go to next message
Colin White is currently offline Colin WhiteFriend
Messages: 2
Registered: July 2011
Junior Member
Hi,

I've written a short program to flood fill a simple black and white image of the outline of a cell (I'm using ImageJ). The image is too big to do this recursively (about 400x400 pixels) so I've used queues. However, my program only runs for a short while and then returns and out of memory error. I'm really not sure why it ends up using an upwards of 400MB of memory before it crashes.

Thanks,
-Colin

import ij.*; 
import ij.plugin.filter.PlugInFilter; 
import ij.process.*; 
import ij.gui.*; 
import java.awt.*; 
import java.util.*; 
import java.lang.Math.*; 

public class Filopodia_Analyzer implements PlugInFilter{ 
        ImagePlus analyzed; 

        public int setup(String arg, ImagePlus analyzed){ 
                return DOES_ALL; 
        } 

        public void run(ImageProcessor anal_ip){ 

                Point n = new Point(); 

                ArrayDeque<Point> q = new ArrayDeque<Point>(); 

                if(anal_ip.getPixelValue(12, 10) == 255.0) q.offer(new Point(12, 10)); 

                while(q.size() != 0){ 
                        n = q.poll(); 
                        if(anal_ip.getPixelValue(n.x, n.y) == 255.0) anal_ip.putPixel(n.x, n.y, 223); 

                        if(anal_ip.getPixelValue(n.x-1, n.y) == 255.0) q.offer(new Point(n.x-1, n.y)); 
                        if(anal_ip.getPixelValue(n.x+1, n.y) == 255.0) q.offer(new Point(n.x+1, n.y)); 
                        if(anal_ip.getPixelValue(n.x, n.y-1) == 255.0) q.offer(new Point(n.x, n.y-1)); 
                        if(anal_ip.getPixelValue(n.x, n.y+1) == 255.0) q.offer(new Point(n.x, n.y+1)); 
                        analyzed.updateAndDraw(); 
                } 
        } 
}
Re: ImageJ Flood Fill [message #699495 is a reply to message #699467] Thu, 21 July 2011 16:18 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

Is this an Eclipse question?

On 21-Jul-11 09:23, Colin White wrote:
> Hi,
> I've written a short program to flood fill a simple black and white
> image of the outline of a cell (I'm using ImageJ). The image is too big
> to do this recursively (about 400x400 pixels) so I've used queues.
> However, my program only runs for a short while and then returns and out
> of memory error. I'm really not sure why it ends up using an upwards of
> 400MB of memory before it crashes.
> Thanks,
> -Colin
> import ij.*; import ij.plugin.filter.PlugInFilter; import ij.process.*;
> import ij.gui.*; import java.awt.*; import java.util.*; import
> java.lang.Math.*;
> public class Filopodia_Analyzer implements PlugInFilter{ ImagePlus
> analyzed;
> public int setup(String arg, ImagePlus analyzed){ return DOES_ALL; }
> public void run(ImageProcessor anal_ip){
> Point n = new Point();
> ArrayDeque<Point> q = new ArrayDeque<Point>();
> if(anal_ip.getPixelValue(12, 10) == 255.0) q.offer(new Point(12, 10));
> while(q.size() != 0){ n = q.poll(); if(anal_ip.getPixelValue(n.x, n.y)
> == 255.0) anal_ip.putPixel(n.x, n.y, 223);
> if(anal_ip.getPixelValue(n.x-1, n.y) == 255.0) q.offer(new Point(n.x-1,
> n.y)); if(anal_ip.getPixelValue(n.x+1, n.y) == 255.0) q.offer(new
> Point(n.x+1, n.y)); if(anal_ip.getPixelValue(n.x, n.y-1) == 255.0)
> q.offer(new Point(n.x, n.y-1)); if(anal_ip.getPixelValue(n.x, n.y+1) ==
> 255.0) q.offer(new Point(n.x, n.y+1)); analyzed.updateAndDraw(); } } }
Re: ImageJ Flood Fill [message #699525 is a reply to message #699495] Thu, 21 July 2011 17:28 Go to previous messageGo to next message
Colin White is currently offline Colin WhiteFriend
Messages: 2
Registered: July 2011
Junior Member
It was more a general java question about why my program was using so much memory, but I managed to figure out my problem anyway. ImageJ has a class that can perform flood fill.

Thanks,
Colin
Re: ImageJ Flood Fill [message #699553 is a reply to message #699525] Thu, 21 July 2011 18:36 Go to previous message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 21-Jul-11 11:28, Colin White wrote:
> It was more a general java question about why my program was using so
> much memory, but I managed to figure out my problem anyway. ImageJ has a
> class that can perform flood fill.
>
> Thanks,
> Colin

There are really far better forums for Java questions like JavaRanch,
stackOverflow and JGuru. Glad you figured it out!
Previous Topic:No basic functions in eclipse for cpp ?
Next Topic:Startup Problem
Goto Forum:
  


Current Time: Fri Apr 19 21:31:00 GMT 2024

Powered by FUDForum. Page generated in 0.08518 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top