Hi Maximilien,<br><br>A) For pasting the values back in to the image, <br>     you may want to use the MaskImageFilter or<br>     the NegatedMaskImageFilter.<br><br><br>B) Most ITK filters are N-Dimensional. <br>     The region growing filters will work fine in <br>
     2D, 3D, 4D....<br><br>C) You may start by debugging your process of<br>     copying images in and out of ITK. It doesn&#39;t<br>     seem that your problem is related to the<br>     region growing itself.<br><br><br>
  Regards,<br><br><br>        Luis<br><br><br>------------------------------------------------<br><div class="gmail_quote">On Sat, Jul 25, 2009 at 6:17 AM, Maximilien Renard <span dir="ltr">&lt;<a href="mailto:iixamaxii@gmail.com">iixamaxii@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi there,<br>
<br>
I&#39;m trying to realize a function (Fill3D) that uses the connected<br>
threshold filter to fill a region of a 3D image with another value<br>
based on a threshold.<br>
<br>
This is the function I&#39;m using now :<br>
<br>
void CVolumeData::Fill3D(int X, int Y, int Z, unsigned short<br>
LowThreshold, unsigned short HighThreshold, unsigned short<br>
ReplacementValue) {<br>
        typedef itk::ConnectedThresholdImageFilter &lt; ITK3DImageType,<br>
ITK3DImageType&gt; FilterType;<br>
        FilterType::Pointer filter = FilterType::New();<br>
        ITK3DImageType::IndexType seed;<br>
        seed[0] = X;<br>
        seed[1] = Y;<br>
        seed[2] = Z;<br>
        CVolumeData *pResultImage;<br>
        int DimX, DimY, DimZ, x, y, z;<br>
<br>
        filter-&gt;SetSeed(seed);<br>
        filter-&gt;SetLower(LowThreshold);<br>
        filter-&gt;SetUpper(HighThreshold);<br>
        filter-&gt;SetReplaceValue(4000);<br>
<br>
        filter-&gt;SetInput(GetITK3DImage());<br>
        filter-&gt;Update();<br>
        pResultImage = new CVolumeData(m_MainView);<br>
        pResultImage-&gt;SetITK3DImage(filter-&gt;GetOutput());<br>
<br>
        GetDimensions(DimX, DimY, DimZ);<br>
<br>
        for (z = 0; z &lt; DimZ; z++)<br>
                for (y = 0; y &lt; DimY; y++)<br>
                        for (x = 0; x &lt; DimX; x++) {<br>
                                if (pResultImage-&gt;GetVoxel(x, y, z) &gt;= 4000) {<br>
                                        SetVoxel(x, y, z, ReplacementValue);<br>
                                }<br>
                        }<br>
<br>
        delete(pResultImage);<br>
}<br>
<br>
The last 3 for (DimZ, DimY and DimX) are necessary to replace the<br>
filled zone in the original image without replacing the zone of the<br>
original image which lies outside the threshold values. Sadly it takes<br>
lots of time. Is there a better way to do this ?<br>
<br>
Next question, I need to do a Fill2D function too. Here again I have a<br>
problem. I use the extract image filter to extract the slice I need,<br>
then I apply the Fill3D filter on the image (Fill3D that doesn&#39;t work<br>
properly now) and what I wanted to do is use the PasteImageFilter to<br>
paste the result of the Fill3D (which has only one slice) back into<br>
the original 3D Image.<br>
<br>
But once again it doesn&#39;t work. The result is that the new slice is<br>
entirely black...<br>
<br>
void CVolumeData::Fill2D(int X, int Y, int Z, unsigned short<br>
LowThreshold, unsigned short HighThreshold, unsigned short<br>
ReplacementValue, int SubView) {<br>
        int DimX, DimY, DimZ;<br>
        int x, y, z;<br>
<br>
        GetDimensions(DimX, DimY, DimZ);<br>
<br>
        typedef itk::ExtractImageFilter&lt; ITK3DImageType, ITK3DImageType &gt; FilterType;<br>
        FilterType::Pointer filter = FilterType::New();<br>
<br>
        ITK3DImageType::RegionType inputRegion =<br>
GetITK3DImage()-&gt;GetLargestPossibleRegion();<br>
<br>
        if (SubView == CMainView::MODE_XY) {<br>
                CVolumeData SliceVolume(m_MainView);<br>
<br>
                SliceVolume.CreateVolume(DimX, DimY, 1, 1.0f, 1.0f, 1.0f, 0, false);<br>
<br>
                ITK3DImageType::SizeType size = inputRegion.GetSize();<br>
                size[2] = 1;<br>
                ITK3DImageType::IndexType start = inputRegion.GetIndex();<br>
                start[2] = Z;<br>
                ITK3DImageType::RegionType desiredRegion;<br>
                desiredRegion.SetSize(size);<br>
                desiredRegion.SetIndex(start);<br>
<br>
                filter-&gt;SetExtractionRegion(desiredRegion);<br>
<br>
                filter-&gt;SetInput(GetITK3DImage());<br>
<br>
                filter-&gt;Update();<br>
<br>
                SliceVolume.SetITK3DImage(filter-&gt;GetOutput());<br>
<br>
                SliceVolume.Fill3D(X, Y, 0, LowThreshold, HighThreshold, ReplacementValue);<br>
<br>
                typedef itk::PasteImageFilter&lt; ITK3DImageType, ITK3DImageType,<br>
ITK3DImageType &gt; ImageReplacementFilterType;<br>
                ImageReplacementFilterType::Pointer ImageReplacementFilter =<br>
ImageReplacementFilterType::New();<br>
<br>
                ImageReplacementFilter-&gt;SetSourceImage(SliceVolume.GetITK3DImage());<br>
                ImageReplacementFilter-&gt;SetSourceRegion(SliceVolume.GetITK3DImage()-&gt;GetLargestPossibleRegion());<br>
<br>
                ImageReplacementFilter-&gt;SetDestinationImage(GetITK3DImage());<br>
                ImageReplacementFilter-&gt;SetDestinationIndex(start);<br>
<br>
                ImageReplacementFilter-&gt;Update();<br>
                SetITK3DImage(ImageReplacementFilter-&gt;GetOutput());<br>
        }<br>
}<br>
<br>
I&#39;d enjoy any kind of help !<br>
<br>
Thank you very much,<br>
<br>
Best regards,<br>
<br>
<br>
Maximilien Renard<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 ITK FAQ at: <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</blockquote></div><br>