<div dir="ltr">Thanks for the directions.. Here is what I did:<br><br>blended_image->SetInput(blank_image);<br>blended_image->AddInput(red_image);<br>blended_image->SetSencil(image_stencil_data);<br>blended_image->Update();<br>
<br><br>Am I missing something here? Setting the stencil is not having any effect on the output. I am only getting a bled of blank_image and red_image.<br><br>Thanks,<br>Prathamesh<br><br><div class="gmail_quote">On Fri, Jul 16, 2010 at 11:38 AM, David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">In vtkImageBlend, you need to have two inputs or else the filter will<br>
do nothing. The first input to vtkImageBlend is the background image,<br>
and the second inputs is pasted on top of the first image, using the<br>
stencil to specify a cut-out region.<br>
<br>
So if you want to make several colored regions, you need to have<br>
several solid-colored images to start with, and then paste each one on<br>
top of your background using the proper stencil for that color. Use<br>
several vtkImageBlend filters in a chain, each one will add another<br>
colored region to the image.<br>
<br>
You can create a solid-colored image by creating a vtkLookupTable that<br>
has just one color, and pass an input image of the desired sized<br>
through vtkImageMapToColors to map the image to that color. For the<br>
background, you can either use your original image (mapped to RBG so<br>
that other images can be blended on top of it), or you can use a black<br>
image created by mapping your original image through a black lookup<br>
table.<br>
<br>
David<br>
<br>
<br>
On Thu, Jul 15, 2010 at 11:05 PM, Prathamesh Kulkarni<br>
<div><div></div><div class="h5"><<a href="mailto:prathameshmkulkarni@gmail.com">prathameshmkulkarni@gmail.com</a>> wrote:<br>
> I managed to add more than one stencils by using the<br>
> combined_vtkImageStencilData->Add(new_vtkImageStencilData) and then setting<br>
> vtkImageStencil->AddStencil(combined_vtkImageStencilData);<br>
> However, I have not been able to figure out a way to set the foreground<br>
> color of any stencil to a given value. The aim is to show every stencil with<br>
> a different color in the vtkImageData (= vtkImageStencil->GetOutput()).<br>
> Any help will be highly appreciated.<br>
><br>
> Thanks,<br>
> Prathamesh<br>
> On Thu, Jul 15, 2010 at 6:52 PM, Prathamesh Kulkarni<br>
> <<a href="mailto:prathameshmkulkarni@gmail.com">prathameshmkulkarni@gmail.com</a>> wrote:<br>
>><br>
>> I managed use vtkImageStencil and vtkImageAccumulate, but could not get a<br>
>> proper blended image output with vtkImageBlend. Following is my code snippet<br>
>> for vtkImageBlend:<br>
>><br>
>> blended_image->SetInput(image_data);<br>
>> blended_image->SetStencil(image_stencil_data);<br>
>><br>
>> blended_image->SetOpacity(1, opacity)<br>
>> blended_image->Update();<br>
>><br>
>> When I try to render blended_image->GetOutput(), I simply get the input<br>
>> image, as if setting the stencil had no effect. I expected to see a<br>
>> different opacity in the stencil region. Please tell me if I am missing<br>
>> anything here.<br>
>><br>
>><br>
>> Also, I was wondering how to add multiple stencils to vtkImageStencil so<br>
>> that at the output I can have a vtkImageData showing multiple stencils with<br>
>> different colors.<br>
>><br>
>> In any case, I did not understand how to set the foreground color of a<br>
>> single stencil.<br>
>><br>
>><br>
>><br>
>> Sorry for putting in 3 questions together.. Thanks for your answers in<br>
>> advance.<br>
>><br>
>><br>
>> Prathamesh<br>
>><br>
>><br>
>> On Wed, Jul 14, 2010 at 5:31 PM, David Gobbi <<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>><br>
>> wrote:<br>
>>><br>
>>> Hi Prathamesh,<br>
>>><br>
>>> You should use either vtkClipVolume or vtkImageStencil, based on what<br>
>>> you want as an output. The vtkClipVolume filter will output an<br>
>>> unstructured grid, i.e. it will produce a geometric data set<br>
>>> consisting of voxel cells (each voxel cell will be a little cube with<br>
>>> eight points at its corners). If you want the output to be an actual<br>
>>> image, with the background set to black or to transparent, then you<br>
>>> should use vtkImageStencil.<br>
>>><br>
>>> In either case, the best place to start is vtkImplicitLoop, which<br>
>>> takes a contour and produces an "implicit function", which in<br>
>>> VTK-speak, is a function used to define the inside vs. the outside of<br>
>>> a selection area. Then the vtkImplicitLoop can be used as an input to<br>
>>> vtkImplicitFunctionToImageStencil. The output of<br>
>>> vtkImplicitFunctionToImageStencil can then be used as an input to e.g.<br>
>>> vtkImageBlend (for pasting a cut-out image onto another image),<br>
>>> vtkImageStencil (for blacking out the non-selected region of the<br>
>>> image), or vtkImageAccumulate (for computing the average value,<br>
>>> standard deviation, or the histogram of the image area inside the<br>
>>> stencil).<br>
>>><br>
>>> David<br>
>>><br>
>>><br>
>>><br>
>>><br>
>>> On Wed, Jul 14, 2010 at 4:13 PM, Prathamesh Kulkarni<br>
>>> <<a href="mailto:prathameshmkulkarni@gmail.com">prathameshmkulkarni@gmail.com</a>> wrote:<br>
>>> ><br>
>>> > Hello all,<br>
>>> ><br>
>>> > I want to extract a sub-image from vtkImageData given a closed set of<br>
>>> > points<br>
>>> > forming any arbitrary shape (may be a vtkPolyData).<br>
>>> ><br>
>>> > I have been looking at vtk classes like vtkClipVolume, vtkExtractVOI,<br>
>>> > vtkImageStencil. I am no able to understand which way should be<br>
>>> > preferred<br>
>>> > over which to do my task. Also, I am not able to figure out the exact<br>
>>> > pipeline structure for these clipping methods.<br>
>>> ><br>
>>> > Could someone please throw some light on this?<br>
>>> ><br>
>>> > Thanks,<br>
>>> > Prathamesh<br>
>>> ><br>
>>> > _______________________________________________<br>
>>> > Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>>> ><br>
>>> > Visit other Kitware open-source projects at<br>
>>> > <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:<br>
>>> > <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://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
>>> ><br>
>>> ><br>
>><br>
><br>
><br>
</div></div></blockquote></div><br></div>