Hello!<br><br>Finally, I got it! I found an example in /Examples/IO called <b>ImageReadExtractFilterInsertWrite.cxx</b> which does the job. I was so overwhelmed by all the information, that I didn&#39;t see this in the first place.<br>
<br>AD<br><div class="yj6qo ajU"><div id=":6h" class="ajR" tabindex="0"><img class="ajT" src="https://mail.google.com/mail/images/cleardot.gif"></div></div><br><br><div class="gmail_quote">2012/8/20 A D <span dir="ltr">&lt;<a href="mailto:callidus.713@gmail.com" target="_blank">callidus.713@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear ITK-Users!<br><br>I have problems to paste an extracted and edited slice back into its 3D Volume. I tried this with the <b>PasteImageFilter </b>with the <b>SetInPlace</b>(true), but it doesn&#39;t change the actual 3D Volume after reinserting the slice! <br>

<br>Yours Thankfully, AD<br><br>Here is the code I have used, have anyone an idea, why it doesn&#39;t work?<br><br>#include &quot;itkImage.h&quot;<br>#include &quot;itkImageFileReader.h&quot;<br><br>#include &quot;itkExtractImageFilter.h&quot;<br>

#include &quot;itkAnalyzeImageIO.h&quot;<br><br>#include &quot;itkSmartPointer.h&quot;<br><br>#include &quot;itkPasteImageFilter.h&quot;<br>#include &quot;itkOrientImageFilter.h&quot;<br>#include &quot;itkCastImageFilter.h&quot;<br>

#include &quot;itkImageFileWriter.h&quot;<br>#include &quot;itkInPlaceImageFilter.h&quot;<br>#include &quot;itkBinaryThresholdImageFilter.h&quot;<br><br>typedef float        InputPixelType3D;<br>typedef float        OutputPixelType2D;<br>

<br>typedef itk::Image&lt; InputPixelType3D,  3 &gt;    InputImageType3D;<br>typedef itk::Image&lt; OutputPixelType2D, 2 &gt;    OutputImageType2D;<br><br>typedef itk::ImageFileReader&lt; InputImageType3D  &gt;  ReaderType3D;<br>

typedef itk::CastImageFilter&lt; OutputImageType2D, InputImageType3D &gt; Cast2Dto3DImageFilter;<br>typedef itk::ExtractImageFilter&lt; InputImageType3D, OutputImageType2D &gt; ExtractImageFilter;<br>typedef itk::InPlaceImageFilter &lt; InputImageType3D, InputImageType3D&gt;  InPlaceImageFilter;<br>

typedef itk::PasteImageFilter &lt; InputImageType3D,  InputImageType3D&gt; PasteImageFilterType;<br>typedef itk::BinaryThresholdImageFilter&lt; OutputImageType2D, OutputImageType2D &gt; BinaryThresholdFilterType;<br>typedef float   PixelType;<br>

<br>typedef itk::ImageFileReader&lt; OutputImageType2D &gt; ReaderType;<br><br>InputImageType3D::IndexType m_start;<br><br>OutputImageType2D::Pointer extract2DImageSlice(InputImageType3D::Pointer volume, int plane, int slice) {<br>

    ExtractImageFilter::Pointer filter = ExtractImageFilter::New();<br>    <br>    InputImageType3D::RegionType inputRegion =<br>        volume-&gt;GetLargestPossibleRegion();<br><br>    InputImageType3D::SizeType m_size;<br>

    m_size = inputRegion.GetSize();<br>    m_size[plane] = 0;<br>    <br>    m_start = inputRegion.GetIndex();<br>    <br>    const unsigned int sliceNumber = slice;<br>    m_start[plane] = sliceNumber;<br>    <br>    InputImageType3D::RegionType desiredRegion;<br>

    desiredRegion.SetSize(  m_size  );<br>    desiredRegion.SetIndex( m_start );<br>    filter-&gt;SetExtractionRegion( desiredRegion );<br><br>    filter-&gt;SetInput( volume );<br><br>    filter-&gt;Update();<br><br>    return filter-&gt;GetOutput();<br>

}<br><br><br>InputImageType3D::Pointer ReadAnalyzeFile(const char *path)<br>{<br>    itk::AnalyzeImageIO::Pointer io = itk::AnalyzeImageIO::New();<br>    ReaderType3D::Pointer fileReader = ReaderType3D::New();<br>    fileReader-&gt;SetImageIO(io);<br>

    fileReader-&gt;SetFileName(path);<br>    fileReader-&gt;Update();<br>    <br>    itk::OrientImageFilter&lt;InputImageType3D,InputImageType3D&gt;::Pointer orienter =<br>    itk::OrientImageFilter&lt;InputImageType3D,InputImageType3D&gt;::New();<br>

    orienter-&gt;UseImageDirectionOn();<br>    orienter-&gt;SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_IRA);<br>    orienter-&gt;SetInput(fileReader-&gt;GetOutput());<br>    orienter-&gt;Update();<br>

<br>    return orienter-&gt;GetOutput();<br> }<br><br>  OutputImageType2D::Pointer performBinaryThreshold(OutputImageType2D::Pointer slice, std::vector&lt;float&gt; filterParameter) {<br>        BinaryThresholdFilterType::Pointer filter = BinaryThresholdFilterType::New();<br>

<br>        filter-&gt;SetInput( slice );<br>        filter-&gt;SetOutsideValue(0); //outsideValue<br>        filter-&gt;SetInsideValue(255); //insideValue<br>        filter-&gt;SetLowerThreshold(filterParameter[0]); //lowerThreshold*/<br>

        filter-&gt;SetUpperThreshold(filterParameter[1]); //upperThreshold<br>        filter-&gt;Update();<br>    <br>        return filter-&gt;GetOutput();  <br>    }<br><br>void main() {<br>    InputImageType3D::Pointer volume = ReadAnalyzeFile( &quot;Volume.hdr&quot; );<br>

    OutputImageType2D::Pointer slice = extract2DImageSlice( volume, 0,  1);<br>    <br>    std::vector&lt;float&gt; param;<br>    param.push_back(200);<br>    param.push_back(255);<br><br>    OutputImageType2D::Pointer binaryMask = performBinaryThreshold(slice, param);<br>

<br>    Cast2Dto3DImageFilter::Pointer castFilter = Cast2Dto3DImageFilter::New();<br>    castFilter-&gt;SetInput(binaryMask);<br>    castFilter-&gt;Update();<br><br>    PasteImageFilterType::Pointer pasteImageFilter = PasteImageFilterType::New();<br>

    <br>    pasteImageFilter-&gt;SetSourceRegion( castFilter-&gt;GetOutput()-&gt;GetLargestPossibleRegion().GetSize() );<br>    pasteImageFilter-&gt;SetSourceImage( castFilter-&gt;GetOutput() );<br><br>    pasteImageFilter-&gt;SetDestinationIndex( m_start );<br>

    pasteImageFilter-&gt;SetDestinationImage( volume );<br>    pasteImageFilter-&gt;SetInPlace(true);<br><br>    pasteImageFilter-&gt;Update();<br><br>    volume = pasteImageFilter-&gt;GetOutput();<br>    volume-&gt;Update();<br>

<br>    std::cout &lt;&lt; &quot;Done!&quot;;<br>}<br>
</blockquote></div><br>