<div dir="ltr"><div>Hi Chen,</div><div><br></div><div>The easiest way to set the opacity according to the pixel value is to do it with</div><div>the lookup table.  For example, to make dark pixels transparent and bright</div><div>pixels opaque, build an alpha ramp:</div><div><br></div><div>table->SetAlphaRange(0.0, 1.0);</div><div>table->Build();</div><div><br></div><div>Or you can use a for() loop to build the table with SetTableValue(i, r,g,b,a)</div><div>with a different "a" for each table entry.</div><div><br></div><div> - David</div><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 31, 2016 at 2:40 PM, hchen <span dir="ltr"><<a href="mailto:hjchen.work@gmail.com" target="_blank">hjchen.work@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
Does anyone know if there is an efficient way of setting opacity pixelwise,<br>
eg. using luminance of a pixel for its opacity?<br>
<br>
I am writing an application where I need to overlay a few images (eg, a<br>
slice of CT, and then a few planned and measured doses, the doses have a lot<br>
zeros), I have been using SetOpacity in vtkImageBlend or vtkImageProperty,<br>
it works OK, but it feels like the more layers displayed, the duller the<br>
bottom layers becomes. So, I am trying to set opacity for layers( except the<br>
bottom one ) according their pixel value to see if it will do better. As for<br>
now, I first use vtkImageMapToColors to convert to RGBA, then loop through<br>
each pixel using SetComponent in vtkArrayData to set opacity pixelwise. The<br>
program is written in python, so the looping is not particularly efficient.<br>
<br>
If anyone knows a better way of setting opacity on a per-pixel base, I would<br>
appreciate a lot!<br>
<br>
Thanks!<br>
<br>
Chen<br></blockquote></div></div></div>