<div dir="ltr"><br clear="all"><div>I am trying to update just one slice of a vtkImageData by reading it from file, leaving the rest of the volume unchanged.  My code is below. I am trying to limit the region updated by the filter by calling SetUpdateExtent, but I don't think this is doing anything.  When I call UpdateWholeExtent, **all** image slices contain a copy of the 2D image read from file.  If instead I only call Update, then the volume now consists of only one slice.</div>
<div>Note that I don't want to read a sequence of files with structured filenames, I want to read one slice at a time for reasons too tedious to explain here!<br></div><div>Please help!  Thanks in advance.</div><div><br>
</div><div><br></div><div><br></div><div><div><span class="" style="white-space:pre">   </span>int SIZE_X = 722;</div><div><span class="" style="white-space:pre">  </span>int SIZE_Y = 460;</div><div><span class="" style="white-space:pre">  </span>int SIZE_Z = 100;</div>
<div><br></div><div><span class="" style="white-space:pre">   </span>// create volume (16-bit)</div><div><span class="" style="white-space:pre">  </span>m_imageVolume = vtkSmartPointer<vtkImageData>::New();</div><div><span class="" style="white-space:pre">        </span>m_imageVolume->SetExtent(0, SIZE_X-1, 0, SIZE_Y-1, 0, SIZE_Z-1);</div>
<div><span class="" style="white-space:pre">    </span>m_imageVolume->SetSpacing(1.0, 1.0, 1.0);</div><div><span class="" style="white-space:pre">       </span>m_imageVolume->SetOrigin(0.0, 0.0, 0.0);</div><div><span class="" style="white-space:pre">        </span>m_imageVolume->AllocateScalars(VTK_UNSIGNED_SHORT, 1); </div>
<div><br></div><div><span class="" style="white-space:pre">   </span>// set it all mid-grey</div><div><span class="" style="white-space:pre">     </span>unsigned short* volPtr = static_cast<unsigned short*>( m_imageVolume->GetScalarPointer() );</div>
<div><span class="" style="white-space:pre">    </span>memset(volPtr, 30000, SIZE_X * SIZE_Y * SIZE_Z * sizeof(unsigned short) );</div><div><br></div><div><br></div><div><span class="" style="white-space:pre">       </span>int de[6];</div>
<div><span class="" style="white-space:pre">    </span>m_imageVolume->GetExtent( de );</div><div><br></div><div><span class="" style="white-space:pre">        </span>// read data into middle slice</div><div><span class="" style="white-space:pre">     </span>vtkSmartPointer<vtkTIFFReader> reader = vtkSmartPointer<vtkTIFFReader>::New();</div>
<div><span class="" style="white-space:pre">    </span>reader->SetOutput( m_imageVolume );</div><div><span class="" style="white-space:pre">     </span>reader->SetFileName("..... .tif");</div><div><span class="" style="white-space:pre">    </span>reader->SetFileDimensionality(2);</div>
<div><span class="" style="white-space:pre">    </span>reader->SetDataExtent( de );</div><div><br></div><div><span class="" style="white-space:pre">   </span>int updateExtent[6];</div><div><span class="" style="white-space:pre">       </span>updateExtent[0] = 0;</div>
<div><span class="" style="white-space:pre">    </span>updateExtent[1] = SIZE_X-1;</div><div><span class="" style="white-space:pre">        </span>updateExtent[2] = 0;</div><div><span class="" style="white-space:pre">       </span>updateExtent[3] = SIZE_Y-1;</div>
<div><span class="" style="white-space:pre">    </span>updateExtent[4] = SIZE_Z/2;</div><div><span class="" style="white-space:pre">        </span>updateExtent[5] = SIZE_Z/2;</div><div><span class="" style="white-space:pre">        </span>reader->SetUpdateExtent( updateExtent );</div>
<div><br></div><div><span class="" style="white-space:pre">   </span>reader->SetOrientationType( ORIENTATION_BOTLEFT );  // otherwise it comes out upside down</div><div><span class="" style="white-space:pre">       </span>//reader->Update();<span class="" style="white-space:pre">                                    </span>// volume has only one slice</div>
<div><span class="" style="white-space:pre">    </span>reader->UpdateWholeExtent();<span class="" style="white-space:pre">           </span>// volume has many slices all containing the image read from file</div></div>
</div>