<div dir="ltr"><div class="markdown-here-wrapper" style="font-family:"Lucida Sans",Cantarell,Verdana,sans-serif;color:rgb(11,83,148)"><p style="margin:0px 0px 1.2em!important">Hi,</p>
<p style="margin:0px 0px 1.2em!important">The code you shared seems fine to me.<br>I see the image you shared but could you please describe what we’re looking at and what we expect to see?</p>
<p style="margin:0px 0px 1.2em!important">It would help to identify the issue by removing all additional logic and minimizing the test case.<br>Do you see the issue without the gradient opacity function and masking?</p>
<p style="margin:0px 0px 1.2em!important">Thanks,<br>Sankhesh</p>
<div title="MDH:SGksPGRpdj48YnI+PC9kaXY+PGRpdj5UaGUgY29kZSB5b3Ugc2hhcmVkIHNlZW1zIGZpbmUgdG8g
bWUuPC9kaXY+PGRpdj5JIHNlZSB0aGUgaW1hZ2UgeW91IHNoYXJlZCBidXQgY291bGQgeW91IHBs
ZWFzZSBkZXNjcmliZSB3aGF0IHdlJ3JlIGxvb2tpbmcgYXQgYW5kIHdoYXQgd2UgZXhwZWN0IHRv
IHNlZT88L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2Pkl0IHdvdWxkIGhlbHAgdG8gaWRlbnRpZnkg
dGhlIGlzc3VlIGJ5IHJlbW92aW5nIGFsbCBhZGRpdGlvbmFsIGxvZ2ljIGFuZCBtaW5pbWl6aW5n
IHRoZSB0ZXN0IGNhc2UuPC9kaXY+PGRpdj5EbyB5b3Ugc2VlIHRoZSBpc3N1ZSB3aXRob3V0IHRo
ZSBncmFkaWVudCBvcGFjaXR5IGZ1bmN0aW9uIGFuZCBtYXNraW5nPzwvZGl2PjxkaXY+PGJyPjwv
ZGl2PjxkaXY+VGhhbmtzLDwvZGl2PjxkaXY+U2Fua2hlc2g8L2Rpdj48ZGl2Pjxicj48L2Rpdj4=" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0">​</div></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jun 14, 2018 at 6:50 AM terminator via vtkusers <<a href="mailto:vtkusers@public.kitware.com">vtkusers@public.kitware.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Of curse,<br>
It's the output:<br>
<<a href="http://vtk.1045678.n5.nabble.com/file/t342452/output-vtk.jpg" rel="noreferrer" target="_blank">http://vtk.1045678.n5.nabble.com/file/t342452/output-vtk.jpg</a>> <br>
<br>
And this is the code:<br>
<br>
#include <vtkRenderer.h><br>
#include <vtkRenderWindow.h><br>
#include <vtkRenderWindowInteractor.h><br>
#include <vtkSmartPointer.h><br>
#include <vtkTIFFReader.h><br>
#include <vtk_tiff.h><br>
#include <vtkVolume.h><br>
#include <vtkSmartVolumeMapper.h><br>
#include <vtkGPUVolumeRayCastMapper.h><br>
#include <vtkOpenGLGPUVolumeRayCastMapper.h><br>
#include <vtkImageData.h><br>
#include <vtkVolumeProperty.h><br>
#include <vtkPiecewiseFunction.h><br>
#include <vtkColorTransferFunction.h><br>
#include <vtkStringArray.h><br>
#include <vtkStdString.h><br>
#include <string><br>
<br>
#define PIC_STEP 5<br>
int main(int, char *[])<br>
{<br>
        int start = 3785, end = 4285;<br>
        std::string ctPath = "..\\CTDATA\\";<br>
        std::string maskPath = "..\\labelmap\\";<br>
        vtkSmartPointer<vtkTIFFReader> ctReader =<br>
vtkSmartPointer<vtkTIFFReader>::New();<br>
        vtkSmartPointer<vtkTIFFReader> maskReader =<br>
vtkSmartPointer<vtkTIFFReader>::New();<br>
        vtkImageData * ctImages;<br>
        vtkImageData * maskImages;<br>
        vtkVolume * volume;<br>
        vtkGPUVolumeRayCastMapper * vMap;<br>
        vtkVolumeProperty * vProp;<br>
        vtkPiecewiseFunction * tf[3];<br>
        vtkColorTransferFunction * cf[3];<br>
<br>
<br>
        int pic_num = start;<br>
        ctReader->SetFileName((ctPath + std::to_string(pic_num) + ".tif").c_str());<br>
        ctReader->Update();<br>
        int * extents = ctReader->GetOutput()->GetExtent();<br>
<br>
<br>
        vtkStdString * ctFileNames = new vtkStdString[(end - start) / PIC_STEP +<br>
1];<br>
        vtkStdString * maskFileNames = new vtkStdString[(end - start) / PIC_STEP +<br>
1];<br>
        int i = 0;<br>
        for (int pic_num = start; pic_num <= end; pic_num += PIC_STEP) {<br>
                ctFileNames[i] = ctPath + std::to_string(pic_num) + ".tif";<br>
                maskFileNames[i] = maskPath + std::to_string(pic_num) + ".tif";<br>
                i++;<br>
        }<br>
        vtkStringArray * ctFileNameArr = vtkStringArray::New();<br>
        vtkStringArray * maskFileNameArr = vtkStringArray::New();<br>
        ctFileNameArr->SetArray(ctFileNames, (end - start) / PIC_STEP + 1, 0);<br>
        maskFileNameArr->SetArray(maskFileNames, (end - start) / PIC_STEP + 1, 0);<br>
        std::cout << "Slices: " << (end - start) / PIC_STEP << std::endl;<br>
        ctReader->SetDataExtent(extents[0], extents[1], extents[2], extents[3], 0,<br>
((end - start) / PIC_STEP));<br>
        ctReader->SetFileNames(ctFileNameArr);<br>
        ctReader->Update();<br>
        ctImages = ctReader->GetOutput();<br>
        maskReader->SetDataExtent(extents[0], extents[1], extents[2], extents[3],<br>
0, ((end - start) / PIC_STEP));<br>
        maskReader->SetFileNames(maskFileNameArr);<br>
        maskReader->SetOrientationType(ORIENTATION_LEFTBOT);<br>
        maskReader->Update();<br>
        maskImages = maskReader->GetOutput();<br>
<br>
        //Opacity TF<br>
        tf[0] = vtkPiecewiseFunction::New();<br>
        tf[0]->AddPoint(20, 0);<br>
        tf[0]->AddPoint(255, 0.2);<br>
        tf[1] = vtkPiecewiseFunction::New();<br>
        tf[1]->AddPoint(0, 1);<br>
        tf[1]->AddPoint(255, 1);<br>
        tf[2] = vtkPiecewiseFunction::New();<br>
        tf[2]->AddPoint(0, 0);<br>
        tf[2]->AddPoint(255, 0);<br>
        //Color TF<br>
        cf[0] = vtkColorTransferFunction::New();<br>
        cf[0]->AddRGBPoint(0, 0, 0, 0);<br>
        cf[0]->AddRGBPoint(255, 1, 1, 1);<br>
        cf[1] = vtkColorTransferFunction::New();<br>
        cf[1]->AddRGBPoint(0, 1, 0, 0);<br>
        cf[1]->AddRGBPoint(255, 1, 0, 0);<br>
        cf[2] = vtkColorTransferFunction::New();<br>
        cf[2]->AddRGBPoint(0, 0, 0, 1);<br>
        cf[2]->AddRGBPoint(255, 0, 0, 1);<br>
<br>
        vProp = vtkVolumeProperty::New();<br>
        vProp->IndependentComponentsOn();<br>
        vProp->SetScalarOpacity(0, tf[0]);<br>
        vProp->SetGradientOpacity(0, tf[0]);<br>
        vProp->SetScalarOpacity(1, tf[1]);<br>
        vProp->SetGradientOpacity(1, tf[1]);<br>
        vProp->SetScalarOpacity(2, tf[2]);<br>
        vProp->SetGradientOpacity(2, tf[2]);<br>
        vProp->SetColor(0, cf[0]);<br>
        vProp->SetColor(1, cf[1]);<br>
        vProp->SetColor(2, cf[2]);<br>
<br>
<br>
        vMap = vtkGPUVolumeRayCastMapper::New();<br>
        vMap->SetInputData(ctImages);<br>
        vMap->SetMaskTypeToLabelMap();<br>
        vMap->SetMaskBlendFactor(0.8);<br>
        vMap->SetMaskInput(maskImages);<br>
<br>
        volume = vtkVolume::New();<br>
        volume->SetMapper(vMap);<br>
        volume->SetProperty(vProp);<br>
<br>
        vtkRenderer * render = vtkRenderer::New();<br>
        vtkRenderWindow * renderWin = vtkRenderWindow::New();<br>
        vtkRenderWindowInteractor * irenWin = vtkRenderWindowInteractor::New();<br>
        render->SetBackground(0, 0.5, 0.5);<br>
        render->AddVolume(volume);<br>
        renderWin->AddRenderer(render);<br>
        irenWin->SetRenderWindow(renderWin);<br>
        renderWin->Render();<br>
        irenWin->Start();<br>
        return EXIT_SUCCESS;<br>
}<br>
<br>
<br>
<br>
--<br>
Sent from: <a href="http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html" rel="noreferrer" target="_blank">http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html</a><br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">https://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</blockquote></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div class="inbox-inbox-inbox-inbox-inbox-inbox-inbox-markdown-here-wrapper" style="font-family:"proza libre",sans-serif;color:rgb(0,56,107)"><h5 id="inbox-inbox-inbox-inbox-inbox-inbox-inbox-sankhesh-jhaveri" style="margin:1.3em 0px 1em;padding:0px;font-size:1.1em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);font-weight:bold;color:rgb(11,65,148)">Sankhesh Jhaveri</h5>
<h6 id="inbox-inbox-inbox-inbox-inbox-inbox-inbox--sr-research-development-engineer-kitware-http-www-kitware-com-518-881-4417" style="margin:1.3em 0px 1em;padding:0px;font-size:1em;color:rgb(11,83,148);font-family:"open sans",sans-serif;font-weight:normal"><em>Sr. Research & Development Engineer</em> | <a href="http://www.kitware.com/">Kitware</a> | (518) 881-4417</h6>
<div title="MDH:PGIgc3R5bGU9ImZvbnQtZmFtaWx5OiB2ZXJkYW5hLCBzYW5zLXNlcmlmOyBjb2xvcjogcmdiKDEx
LCA4MywgMTQ4KTsiPjxmb250IHNpemU9IjIiPiMjIyMjU2Fua2hlc2ggSmhhdmVyaTwvZm9udD48
L2I+PGRpdj48Zm9udCBjb2xvcj0iIzBiNTM5NCIgZmFjZT0idmVyZGFuYSwgc2Fucy1zZXJpZiIg
c2l6ZT0iMiI+PGI+PGJyPjwvYj48L2ZvbnQ+PGRpdj48c3BhbiBzdHlsZT0iZm9udC1mYW1pbHk6
IGFyaWFsLCBzYW5zLXNlcmlmOyBjb2xvcjogcmdiKDExLCA4MywgMTQ4KTsiPjxzcGFuIHN0eWxl
PSJmb250LWZhbWlseTogdmVyZGFuYSwgc2Fucy1zZXJpZjsiPjxpPiMjIyMjIypTci4gUmVzZWFy
Y2ggJmFtcDsgRGV2ZWxvcG1lbnQgRW5naW5lZXIqPC9pPiZuYnNwO3wmbmJzcDs8L3NwYW4+PC9z
cGFuPjxzcGFuIHN0eWxlPSJmb250LWZhbWlseTogdmVyZGFuYSwgc2Fucy1zZXJpZjsgY29sb3I6
IHJnYigxMSwgODMsIDE0OCk7Ij48YSBocmVmPSJodHRwOi8vd3d3LmtpdHdhcmUuY29tLyIgdGFy
Z2V0PSJfYmxhbmsiIHN0eWxlPSJjb2xvcjogcmdiKDE3LCA4NSwgMjA0KTsiPktpdHdhcmU8L2E+
Jm5ic3A7fCZuYnNwOzwvc3Bhbj48c3BhbiBzdHlsZT0iZm9udC1mYW1pbHk6IHZlcmRhbmEsIHNh
bnMtc2VyaWY7IGNvbG9yOiByZ2IoMTEsIDgzLCAxNDgpOyI+KDUxOCkgODgxLTQ0MTc8L3NwYW4+
PGJyPjwvZGl2PjxkaXY+PGRpdj48ZGl2PjxzcGFuIHN0eWxlPSJmb250LWZhbWlseTogdmVyZGFu
YSwgc2Fucy1zZXJpZjsgY29sb3I6IHJnYigxMSwgODMsIDE0OCk7Ij48L3NwYW4+PC9kaXY+PC9k
aXY+PC9kaXY+PC9kaXY+" style="height:0px;width:0px;max-height:0px;max-width:0px;overflow:hidden;font-size:0em;padding:0px;margin:0px">​</div></div></div></div>