Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about Opacity #46

Open
nkoutroumanis opened this issue Jun 22, 2018 · 2 comments
Open

Question about Opacity #46

nkoutroumanis opened this issue Jun 22, 2018 · 2 comments

Comments

@nkoutroumanis
Copy link

How can i create result of an image with 50% opacity through Java?

@ctrueden
Copy link
Member

ctrueden commented Jun 26, 2018

@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.

@imagejan
Copy link
Member

imagejan commented Jul 2, 2018

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants