filling an image

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

filling an image

Alfredo Ok
This might be a stupid question, but does anyone know how to fill an image
with a single color, such as black, or else to clear an existing image's
pixel values so that it's blank? I'm trying to open an existing image,
erase what's already drawn on it, and then redraw it with what I want, but
so far the erasing part has been troublesome.

I realize that the ImageProcessor class has a function fill(), but when I
do something like this:

ip.setValue(0);
ip.fill();

it doesn't work!! I even tried adding imp.updateAndDraw(); to see if that
would change anything, but it didn't. Is there any other way to accomplish
this, or am I doing something wrong?

Thanks!!
  -alfredo
Reply | Threaded
Open this post in threaded view
|

Re: filling an image

Ludgate, David
You have to select the area you want to fill. Try

Roi r = new Roi(0,0,ip.getWidth(),ip.getHeight())
ip.setRoi(r)
ip.fill();

Cheers,
dave

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
Alfredo Ok
Sent: Saturday, August 06, 2005 12:08 PM
To: [hidden email]
Subject: filling an image


This might be a stupid question, but does anyone know how to fill an
image
with a single color, such as black, or else to clear an existing image's
pixel values so that it's blank? I'm trying to open an existing image,
erase what's already drawn on it, and then redraw it with what I want,
but
so far the erasing part has been troublesome.

I realize that the ImageProcessor class has a function fill(), but when
I
do something like this:

ip.setValue(0);
ip.fill();

it doesn't work!! I even tried adding imp.updateAndDraw(); to see if
that
would change anything, but it didn't. Is there any other way to
accomplish
this, or am I doing something wrong?

Thanks!!
  -alfredo
Reply | Threaded
Open this post in threaded view
|

Re: filling an image

Vergara, Leoncio A.
In reply to this post by Alfredo Ok
I am not sure in image J ( I am new to it), but when working with
another program (metamorph) I use image-math to operate my entire image
(grayscale image) against a constant value using a relational operator
like 'minimum' (aka 'darken' or 'smaller than') or 'maximum' ('lighten'
or 'greater than'). I use 'Minimum' against 'zero' to paint the whole
image black or 'maximum' against 'white' (255 or 4095 depending on bit
depth) to paint the image white. So for black or white images, only need
one step, for any other gray level I operate the result of this first
step against the gray value I want using minimum or maximum again as
needed (prior result being black or white). This operates the whole
image, no need to select areas or ROIs or to care about image size...
Works for me, but I am obviously not a programmer..

Leoncio Vergara MD
Director
Optical Imaging lab.
UTMB
Galveston TX.

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
Alfredo Ok
Sent: Saturday, August 06, 2005 2:08 PM
To: [hidden email]
Subject: filling an image


This might be a stupid question, but does anyone know how to fill an
image with a single color, such as black, or else to clear an existing
image's pixel values so that it's blank? I'm trying to open an existing
image, erase what's already drawn on it, and then redraw it with what I
want, but so far the erasing part has been troublesome.

I realize that the ImageProcessor class has a function fill(), but when
I do something like this:

ip.setValue(0);
ip.fill();

it doesn't work!! I even tried adding imp.updateAndDraw(); to see if
that would change anything, but it didn't. Is there any other way to
accomplish this, or am I doing something wrong?

Thanks!!
  -alfredo