use of alpha channel

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

use of alpha channel

Francesco De Comite
Hi,
I would like to draw overlapping shapes, where the colors of both
overlapping objects mix.
I tried using the alpha channel one can define inside a awt.Color
object, as you can see in the following code :

(primeIP is a ColorProcessor)
> setProcessor("Verifying", primeIP);
>         primeIP.setColor(new java.awt.Color(1f,0f,0f,0.5f));
>         primeIP.fillOval(100, 100, 300, 300);
>         primeIP.setColor(new java.awt.Color(0f,0f,1f,0.5f));
>         primeIP.fillOval(200, 100, 300, 300);

but... nothing happens, the second circle is drawn over the first one,
with no colour mix.
Am I asking too much from imageJ, or do I miss something ?

--
Francesco De Comite
tel (33) 03 28 77 85 72
fax (33) 03 28 77 85 37
www.lifl.fr/~decomite
Reply | Threaded
Open this post in threaded view
|

Re: use of alpha channel

dscho
Hi,

On Tue, 16 Dec 2008, Francesco.Decomite wrote:

> I would like to draw overlapping shapes, where the colors of both
> overlapping objects mix.
>
> I tried using the alpha channel one can define inside a awt.Color
> object.

ImageJ does not support the alpha channel, so you cannot do that using the
ImageJ API.

However, from how I read the code, I expect the createBufferedImage()
method of ColorProcessor to be able to create a BufferedImage that _does_
support painting with transparency.

Note:

- you will have to use BufferedImage's createGraphics() method to
  instantiate a Graphics2D object with which you can paint,

- you will need to call the updateAndDraw() method of ImagePlus, otherwise
  the visible image will not be updated.

- the result will _still_ not have an alpha channel, but be a plain RGB
  image.

Hth,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: use of alpha channel

Michael Schmid
Hi Francesco,

if you don't want to do much coding you could also try the  
Alpha_Channel plugin - as almost all plugins it can be called from a  
macro.
Similar to the method proposed by Johannes, it also results in a one-
plane RGB (or grayscale) image, not in layers that could be modified  
after using the plugin.

The Alpha_Channel plugin:
http://imagejdocu.tudor.lu/doku.php?
id=plugin:utilities:alpha_channel:start

Michael
________________________________________________________________

On 16 Dec 2008, at 14:34, Johannes Schindelin wrote:

> Hi,
>
> On Tue, 16 Dec 2008, Francesco.Decomite wrote:
>
>> I would like to draw overlapping shapes, where the colors of both
>> overlapping objects mix.
>>
>> I tried using the alpha channel one can define inside a awt.Color
>> object.
>
> ImageJ does not support the alpha channel, so you cannot do that  
> using the
> ImageJ API.
>
> However, from how I read the code, I expect the createBufferedImage()
> method of ColorProcessor to be able to create a BufferedImage that  
> _does_
> support painting with transparency.
>
> Note:
>
> - you will have to use BufferedImage's createGraphics() method to
>   instantiate a Graphics2D object with which you can paint,
>
> - you will need to call the updateAndDraw() method of ImagePlus,  
> otherwise
>   the visible image will not be updated.
>
> - the result will _still_ not have an alpha channel, but be a plain  
> RGB
>   image.
>
> Hth,
> Dscho