<div dir="ltr">Thank you for the feedback. That fixed the color problem. I am not sure I understand the use of component 4 though. I am trying to use it to set the opacity of the volume using the volume property SetScalarOpacity with a vtkPiecewiseFunction. The code I am using is:<div>
<br></div><div><div> vtkSmartPointer<vtkPiecewiseFunction> compositeOpacity = </div><div> vtkSmartPointer<vtkPiecewiseFunction>::New();</div><div> compositeOpacity->AddPoint(0.0,0.0);</div><div> compositeOpacity->AddPoint(1.0,0.25);</div>
<div> compositeOpacity->AddPoint(255.0,0.25);</div><div> volumeProperty->SetScalarOpacity(3,compositeOpacity);</div></div><div><br></div><div>I set the portions of the volume I want to have not visible to 0 on the fourth channel of the volume (component 3) and then am trying to set the opacity to 0 for those positions using the code above. I am not getting a change in the opacity using this. Is there another way to accomplish this, or have I just made an error in the above?</div>
<div><br></div><div>Thanks.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jun 26, 2014 at 12:42 PM, Lisa Avila <span dir="ltr"><<a href="mailto:lisa.avila@kitware.com" target="_blank">lisa.avila@kitware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>Hello Cory,<br><br></div>In the volume property you'll need to indicate that you don't have independent components. That is, by default this is set to true and therefore VTK assumes you are representing separate properties which each of the scalar components (for example pressure and density). In that case, each scalar is passed through its own lookup tables for color and opacity and the resulting values are merged based on the weightings of the components.<br>
<br></div>VTK also supports IA (intensity / alpha) and RGBA data. This must be 2 or 4 component unsigned char data. Once you set it so that your components are not independent, the last component will be considered a scalar lookup into your opacity transfer function, and the first one or three components will be used to represent your color. In the case of 2 component data (IA), that first component will be passed through the color transfer function. In the case of 4 component data (RGBA) those first three components will be directly considered the RGB color of that voxel. <br>
<br></div>Note that if you have 3 component RGB data you'll need to do something to create a 4th component (otherwise you have no concept of alpha and you just have a solid block of color). Typical methods of generating that fourth component include assigning it to be the hue or intensity of the RGB value. For example, with the visible human data we usually assign the fourth component to be hue since the body was encased in a blue gel (we can then set the opacity of the blue hue to be zero, thereby seeing the human inside the cube). <br>
<br></div>Hope this helps.<span class="HOEnZb"><font color="#888888"><br><br>Lisa<br><br></font></span></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div class="">On Wed, Jun 25, 2014 at 1:49 PM, Cory Jones <span dir="ltr"><<a href="mailto:cjayjones@gmail.com" target="_blank">cjayjones@gmail.com</a>></span> wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">I am trying to render a volume from 3D ImageData and I want to be able to control the color of each voxel independently using the color channels. I am able to set the number of scalar components in my ImageData to 3 and set each channel separately. I am rendering using vtkSmartVolumeMapper. Is there a way to set the vtkVolumeProperty so that the image renders the 3 channels as RGB? I have tried using the vtkColorTransferFunction SetColorSpaceToRGB(), but this does not work. Again, I don't want to do scalar color mapping. My current code is:<br>
<div><br></div><div><br></div><div><div> vtkSmartPointer<vtkSmartVolumeMapper> volumeMapper = </div><div> vtkSmartPointer<vtkSmartVolumeMapper>::New();</div><div> volumeMapper->SetBlendModeToComposite(); </div>
<div> volumeMapper->SetInputConnection(outputImageData->GetProducerPort());</div><div><br></div><div> vtkSmartPointer<vtkVolumeProperty> volumeProperty = </div><div> vtkSmartPointer<vtkVolumeProperty>::New();</div>
<div> volumeProperty->ShadeOff();</div><div> volumeProperty->SetInterpolationType(VTK_LINEAR_INTERPOLATION);</div><div> </div><div> vtkSmartPointer<vtkColorTransferFunction> color = </div><div> vtkSmartPointer<vtkColorTransferFunction>::New();</div>
<div> color->SetColorSpaceToRGB();</div><div> volumeProperty->SetColor(color);</div><div><br></div><div> vtkSmartPointer<vtkVolume> volume = </div><div> vtkSmartPointer<vtkVolume>::New();</div><div>
volume->SetMapper(volumeMapper);</div><div> volume->SetProperty(volumeProperty);</div></div></div>
<br></div></div><div class="">_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" 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" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
<br></div></blockquote></div><br></div>
</blockquote></div><br></div>