Open nkoutroumanis opened 6 years ago
@nkoutroumanis The java.awt.image
API lets you create BufferedImage
objects with alpha channel. See e.g. this SO post. But that is not really specific to Trainable Weka Segmentation or ImageJ. Are you asking how to make TWS spit out an image at a different opacity? The short answer is: you can't, but you can paint the TWS output image onto a BufferedImage
at 50% opacity as described in the link.
If you have an ImageRoi
, you can set the opacity using setOpacity(double opacity)
.
For area ROIs (that can be filled), you can use an Overlay
, as illustrated by this Groovy script:
#@ ImagePlus imp
#@ Integer (min=0, max=255) alpha
import java.awt.Color
import ij.gui.Overlay
roi = imp.getRoi()
ovl = new Overlay(roi)
ovl.setFillColor(new Color(255,0,0,alpha))
imp.setOverlay(ovl)
How can i create result of an image with 50% opacity through Java?