<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt">Setting the opacity in the callback would enable me to check the order in which they were added to the renderer:<br><br> if( m_pWidget->m_pDrrActor && m_pWidget->m_pTIFFActor )<br> {<br> vtkPropCollection* props = m_pWidget->m_pRenderer->GetViewProps();<br> props->InitTraversal();<br> vtkProp* prop = NULL;<br> while( prop = props->GetNextProp()
)<br> {<br> if( prop == vtkProp::SafeDownCast(m_pWidget->m_pDrrActor) )<br> {<br> m_pWidget->m_pDrrActor->SetOpacity(1.0);<br> m_pWidget->m_pTIFFActor->SetOpacity(0.5);<br> break;<br> }<br>
if( prop == vtkProp::SafeDownCast(m_pWidget->m_pTIFFActor) )<br> {<br> m_pWidget->m_pTIFFActor->SetOpacity(1.0);<br> m_pWidget->m_pDrrActor->SetOpacity(0.5);<br> break;<br> }<br> }<br> }<br><div><br><span></span></div><div style="color: rgb(0, 0, 0);
font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span>Didn't solve to problem though....</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span>I have made an algorithm that adds an alpha value to the tiff image:</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family:
HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"> vtkImageIterator<T> inIt(inData, outExt);<br> vtkImageIterator<float> outIt(outData, outExt);<br> int numIn = inData->GetNumberOfScalarComponents();<br> float alpha = self->GetAlpha();<br> <br> // Loop through ouput pixels<br> while( !outIt.IsAtEnd() )<br> {<br> T* inSI = inIt.BeginSpan();<br> float* outSI = outIt.BeginSpan();<br> float* outSIEnd = outIt.EndSpan();<br> while( outSI < outSIEnd )<br> {<br> // now process the
components<br> for( int i = 0; i < numIn; ++i )<br> {<br> *outSI = static_cast<float>(*inSI);<br> ++outSI;<br> ++inSI;<br> }<br> *outSI = alpha;<br> ++outSI;<br> }<br> inIt.NextSpan();<br> outIt.NextSpan();<br> }<br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica
Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span>in order to go through vtkImageActor::HasTranslucentPolygonalGeometry() successfully.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span>Didn't solve it either.<br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida
Grande,sans-serif; background-color: transparent; font-style: normal;"><br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span>I checked an older app of me in which I overlayed a transparent binary image on top of its original image. This worked fine using vtkActors. But in the example both images had the same extent and the order of the actors was predetermined. <br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style:
normal;"><span>Maarten<br></span></div><div style="display: block;" class="yahoo_quoted"> <br> <br> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div dir="ltr"> <font size="2" face="Arial"> On Thursday, January 16, 2014 5:30:47 PM, David Gobbi <david.gobbi@gmail.com> wrote:<br> </font> </div> <div class="y_msg_container">On Thu, Jan 16, 2014 at 3:13 PM, Maarten Beek <<a shape="rect" ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>> wrote:<br clear="none">> I think I want to blend 50/50, so I could set the opacity accordingly in a<br clear="none">> callback initiated by a StartRender event?<br clear="none"><br clear="none">You can set the opacity anywhere. You just have to make sure that
the opacity<br clear="none">is set correctly, and you have to make sure that the images are in the<br clear="none">correct order. The thing about the images being in the correct order<br clear="none">is non-negotiable. You have to do it. Playing with depth isn't going<br clear="none">to help. The images actually have to be rendered in the right order<br clear="none">(an opaque image first, and a 50% opacity image after).<br clear="none"><br clear="none">> I have played around with vtkImageStack; I seemed to get only the first (or<br clear="none">> last) image of the stack or (with transparency) all images blended<br clear="none">> together... I want one image of the stack blended with another (2d) image.<br clear="none">> Secondly, I thought creating 100 actors and adding them to a stack was quite<br clear="none">> slow.<br clear="none"><br clear="none">Were you setting layer numbers (in the vtkImageProperty) for the
images that<br clear="none">you added to the stack? Were you setting VisibilityOff for the images that you<br clear="none">didn't want to show, and setting the correct Opacity for the images that you<br clear="none">wanted to blend?<br clear="none"><br clear="none"> David<div class="yqt5310597203" id="yqtfd96381"><br clear="none"><br clear="none"><br clear="none"><br clear="none">> On Thursday, January 16, 2014 4:58:53 PM, David Gobbi<br clear="none">> <<a shape="rect" ymailto="mailto:david.gobbi@gmail.com" href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>> wrote:<br clear="none">> On Thu, Jan 16, 2014 at 2:45 PM, Maarten Beek <<a shape="rect" ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>> wrote:<br clear="none">>> vtkImageActor::HasTranslucentPolygonalGeometry() seems to want image data<br clear="none">>> of<br clear="none">>> type unsigned
char and 2 or 4 components in order to do transparency. I'm<br clear="none">>> using vtkImageShiftScale to get unsigned char and am working on an<br clear="none">>> algorithm<br clear="none">>> to add an alpha component to my one component tiff data. Curious if this<br clear="none">>> does the trick.<br clear="none">><br clear="none">> I strongly suggest that you use vtkImageSliceMapper and vtkImageSlice<br clear="none">> to display your images instead of using vtkImageActor.<br clear="none">><br clear="none">>> I can understand the order is important if one of the actor is opaque, but<br clear="none">>> why would this still be important when both are 50% transparent.<br clear="none">><br clear="none">> That's not how alpha-blending works. If both images are 50%, then the<br clear="none">> frontmost image is displayed at 50%, and the second image gets 25%,<br clear="none">> and the
background gets the remaining 25%. That's how translucency<br clear="none">> works, both in real-life and in computer graphics.<br clear="none">><br clear="none">> If you want to blend images 50/50, then the frontmost image should have<br clear="none">> 50% opacity and the backmost image should have 100% opacity.<br clear="none">><br clear="none">>> In my app the loading of each image is initiated through a button. I would<br clear="none">>> like to create an app which is independent of the order in which the user<br clear="none">>> clicks these buttons.<br clear="none">><br clear="none">> Order is crucial. That's why I recommend that you use vtkImageStack.<br clear="none">> It makes it possible to explicitly set the layer number for each image.<br clear="none">><br clear="none">> - David<br clear="none">><br clear="none">><br clear="none">><br clear="none">>> On Thursday,
January 16, 2014 3:25:11 PM, David Gobbi<br clear="none">>> <<a shape="rect" ymailto="mailto:david.gobbi@gmail.com" href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>> wrote:<br clear="none">>> Are you using vtk-master (or perhaps a vtk 6.1 release candidate)?<br clear="none">>> The TIFF reader had a serious multi-frame bug in older versions.<br clear="none">>><br clear="none">>> First, note that the vtkTIFFReader doesn't just give you the raw data<br clear="none">>> from the files, it seems to pass it through a lookup table sometimes.<br clear="none">>> And I'm not sure exactly how it deals with alpha, and to be honest,<br clear="none">>> I wouldn't trust it.<br clear="none">>><br clear="none">>> I'm really not sure what you mean when you say "The order of adding<br clear="none">>> the actors to the renderer matters, but I try to avoid this by using<br
clear="none">>> transparency." The order in which you add images is _crucial_ when<br clear="none">>> you are using transparency.<br clear="none">>><br clear="none">>> Are you using the vtkImageStack? It's a class that is designed<br clear="none">>> specifically to handle layered rendering of images.<br clear="none">>><br clear="none">>> David<br clear="none">>><br clear="none">>><br clear="none">>><br clear="none">>> On Thu, Jan 16, 2014 at 12:40 PM, Maarten Beek <<a shape="rect" ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>><br clear="none">>> wrote:<br clear="none">>>> Hi David,<br clear="none">>>><br clear="none">>>> Is it possible to show all images in a multi-paged tiff transparently?<br clear="none">>>><br clear="none">>>> Only when I show the 1st image
(page), I see a 2nd 2d image (both are<br clear="none">>>> transparent).<br clear="none">>>> As soon as I move to another tiff image (page), the 2d image disappears.<br clear="none">>>> It<br clear="none">>>> returns when I move back to the 1st tiff page.<br clear="none">>>><br clear="none">>>> The multi-paged tiff is one component, and I am thinking of an algorithm<br clear="none">>>> to<br clear="none">>>> add an alpha component, but can hardly believe this would be required...<br clear="none">>>><br clear="none">>>> The order of adding the actors to the renderer matters, but I try to<br clear="none">>>> avoid<br clear="none">>>> this by using transparency.<br clear="none">>>><br clear="none">>>> Moving one image in front of the other by changing its z-coordinate using<br clear="none">>>> vtkImageActor::SetPosition()
doesn't help.<br clear="none">>>><br clear="none">>>> Maarten<br clear="none">>>><br clear="none">>>><br clear="none">>>><br clear="none">>>> On Friday, November 8, 2013 4:36:06 PM, Maarten Beek<br clear="none">>>> <<a shape="rect" ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>><br clear="none">>>> wrote:<br clear="none">>>> Hi David,<br clear="none">>>><br clear="none">>>> Using VTK 6.0.0, sorry ;-)<br clear="none">>>><br clear="none">>>> Should I send you the tiff file so you can play with it?<br clear="none">>>><br clear="none">>>> Now I seem to have your attention:<br clear="none">>>><br clear="none">>>> - How do I display a multi-page tif? I don't seem to see the different<br clear="none">>>> images using a vtkImageSlice.<br
clear="none">>>><br clear="none">>>> - What would be good values for the window and level parameters? I am<br clear="none">>>> using<br clear="none">>>> window = range[1]-range[0] and level = 0.5*(range[0]+range[1]) which<br clear="none">>>> works<br clear="none">>>> ok for this multi-page tif, but gets me nowhere when I try to display a<br clear="none">>>> drr.<br clear="none">>>><br clear="none">>>> Thanks - Maarten<br clear="none">>>><br clear="none">>>><br clear="none">>>><br clear="none">>>><br clear="none">>>><br clear="none">>>> On Friday, November 8, 2013 4:23:23 PM, David Gobbi<br clear="none">>>> <<a shape="rect" ymailto="mailto:david.gobbi@gmail.com" href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>><br clear="none">>>> wrote:<br clear="none">>>> Hi Maarten,<br
clear="none">>>><br clear="none">>>> Which version of VTK are you using? I believe that this bug has been<br clear="none">>>> fixed in the master branch by a commits in the following topic merge:<br clear="none">>>> <a shape="rect" href="http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=7e3d5270" target="_blank">http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=7e3d5270</a><br clear="none">>>><br clear="none">>>> It was not fixed in time for VTK 5.10, however.<br clear="none">>>><br clear="none">>>> David<br clear="none">>>><br clear="none">>>><br clear="none">>>> On Fri, Nov 8, 2013 at 2:12 PM, Maarten Beek <<a shape="rect" ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>><br clear="none">>>> wrote:<br clear="none">>>>> Hi all,<br clear="none">>>>><br
clear="none">>>>> vtkTIFFReader crashed for me while loading a multi-paged tiff file.<br clear="none">>>>><br clear="none">>>>> The crash occured in vtkTIFFReader::ReadGenericImage(), because<br clear="none">>>>> this->OutputExtent was not set (still NULL).<br clear="none">>>>> The scalar type for the image I was loading was unsigned short, so it<br clear="none">>>>> happened at line 1368.<br clear="none">>>>><br clear="none">>>>> I changed void vtkTIFFReader::ReadVolume(void* buffer) into void<br clear="none">>>>> vtkTIFFReader::ReadVolume(void* buffer, int outExt[6]) and added the<br clear="none">>>>> line<br clear="none">>>>> this->outputExtent = outExt.<br clear="none">>>>><br clear="none">>>>> This solved my crash.<br clear="none">>>>> I am not sure I am on to something, but
thought to let you know.<br clear="none">>>>><br clear="none">>>>> Maarten<br clear="none">>><br clear="none">>><br clear="none">><br clear="none">><br clear="none"></div><br><br></div> </div> </div> </div> </div></body></html>