<div dir="ltr">Thanks for the directions.. Here is what I did:<br><br>blended_image-&gt;SetInput(blank_image);<br>blended_image-&gt;AddInput(red_image);<br>blended_image-&gt;SetSencil(image_stencil_data);<br>blended_image-&gt;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">&lt;<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>&gt;</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">&lt;<a href="mailto:prathameshmkulkarni@gmail.com">prathameshmkulkarni@gmail.com</a>&gt; wrote:<br>
&gt; I managed to add more than one stencils by using the<br>
&gt; combined_vtkImageStencilData-&gt;Add(new_vtkImageStencilData) and then setting<br>
&gt; vtkImageStencil-&gt;AddStencil(combined_vtkImageStencilData);<br>
&gt; However, I have not been able to figure out a way to set the foreground<br>
&gt; color of any stencil to a given value. The aim is to show every stencil with<br>
&gt; a different color in the vtkImageData (= vtkImageStencil-&gt;GetOutput()).<br>
&gt; Any help will be highly appreciated.<br>
&gt;<br>
&gt; Thanks,<br>
&gt; Prathamesh<br>
&gt; On Thu, Jul 15, 2010 at 6:52 PM, Prathamesh Kulkarni<br>
&gt; &lt;<a href="mailto:prathameshmkulkarni@gmail.com">prathameshmkulkarni@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; I managed use vtkImageStencil and vtkImageAccumulate, but could not get a<br>
&gt;&gt; proper blended image output with vtkImageBlend. Following is my code snippet<br>
&gt;&gt; for vtkImageBlend:<br>
&gt;&gt;<br>
&gt;&gt;         blended_image-&gt;SetInput(image_data);<br>
&gt;&gt;         blended_image-&gt;SetStencil(image_stencil_data);<br>
&gt;&gt;<br>
&gt;&gt;         blended_image-&gt;SetOpacity(1, opacity)<br>
&gt;&gt;         blended_image-&gt;Update();<br>
&gt;&gt;<br>
&gt;&gt; When I try to render blended_image-&gt;GetOutput(), I simply get the input<br>
&gt;&gt; image, as if setting the stencil had no effect. I expected to see a<br>
&gt;&gt; different opacity in the stencil region. Please tell me if I am missing<br>
&gt;&gt; anything here.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Also, I was wondering how to add multiple stencils to vtkImageStencil so<br>
&gt;&gt; that at the output I can have a vtkImageData showing multiple stencils with<br>
&gt;&gt; different colors.<br>
&gt;&gt;<br>
&gt;&gt; In any case, I did not understand how to set the foreground color of a<br>
&gt;&gt; single stencil.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Sorry for putting in 3 questions together.. Thanks for your answers in<br>
&gt;&gt; advance.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Prathamesh<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Wed, Jul 14, 2010 at 5:31 PM, David Gobbi &lt;<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>&gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Hi Prathamesh,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; You should use either vtkClipVolume or vtkImageStencil, based on what<br>
&gt;&gt;&gt; you want as an output. The vtkClipVolume filter will output an<br>
&gt;&gt;&gt; unstructured grid, i.e. it will produce a geometric data set<br>
&gt;&gt;&gt; consisting of voxel cells (each voxel cell will be a little cube with<br>
&gt;&gt;&gt; eight points at its corners).  If you want the output to be an actual<br>
&gt;&gt;&gt; image, with the background set to black or to transparent, then you<br>
&gt;&gt;&gt; should use vtkImageStencil.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; In either case, the best place to start is vtkImplicitLoop, which<br>
&gt;&gt;&gt; takes a contour and produces an &quot;implicit function&quot;, which in<br>
&gt;&gt;&gt; VTK-speak, is a function used to define the inside vs. the outside of<br>
&gt;&gt;&gt; a selection area.  Then the vtkImplicitLoop can be used as an input to<br>
&gt;&gt;&gt; vtkImplicitFunctionToImageStencil.  The output of<br>
&gt;&gt;&gt; vtkImplicitFunctionToImageStencil can then be used as an input to e.g.<br>
&gt;&gt;&gt; vtkImageBlend (for pasting a cut-out image onto another image),<br>
&gt;&gt;&gt; vtkImageStencil (for blacking out the non-selected region of the<br>
&gt;&gt;&gt; image), or vtkImageAccumulate (for computing the average value,<br>
&gt;&gt;&gt; standard deviation, or the histogram of the image area inside the<br>
&gt;&gt;&gt; stencil).<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;   David<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Wed, Jul 14, 2010 at 4:13 PM, Prathamesh Kulkarni<br>
&gt;&gt;&gt; &lt;<a href="mailto:prathameshmkulkarni@gmail.com">prathameshmkulkarni@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; Hello all,<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; I want to extract a sub-image from vtkImageData given a closed set of<br>
&gt;&gt;&gt; &gt; points<br>
&gt;&gt;&gt; &gt; forming any arbitrary shape (may be a vtkPolyData).<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; I have been looking at vtk classes like vtkClipVolume, vtkExtractVOI,<br>
&gt;&gt;&gt; &gt; vtkImageStencil. I am no able to understand which way should be<br>
&gt;&gt;&gt; &gt; preferred<br>
&gt;&gt;&gt; &gt; over which to do my task. Also, I am not able to figure out the exact<br>
&gt;&gt;&gt; &gt; pipeline structure for these clipping methods.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; Could someone please throw some light on this?<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; Thanks,<br>
&gt;&gt;&gt; &gt; Prathamesh<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt;&gt; &gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; Visit other Kitware open-source projects at<br>
&gt;&gt;&gt; &gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; Please keep messages on-topic and check the VTK FAQ at:<br>
&gt;&gt;&gt; &gt; <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; Follow this link to subscribe/unsubscribe:<br>
&gt;&gt;&gt; &gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br></div>