Hi All, I have a method in application that uses ImageReslice and ExtractComponents together to etract the slice z from the 3d image m_imageSrc and fill an imagebuffer using the transform xform as follows:
m_slicer->SetInputConnection(m_imageSrc->GetOutputPort());
m_slicer->SetResliceTransform(xform);
m_slicer->SetOutputOrigin(0,0,0);
m_slicer->SetOutputExtent(0, static_cast<int>(size.x) - 1,
0, static_cast<int>(size.y) - 1,
z, z);
const int extent[6] = { 0, static_cast<int>(size.x) - 1,
0, static_cast<int>(size.y) - 1,
z, z};
m_extractor->SetInputConnection(m_slicer->GetOutputPort());
m_extractor->UpdateExtent(extent);
m_extractor->Update();
im->SetDimensions(static_cast<int>(size.x), static_cast<int>(size.y), 1);
im->AllocateScalars(m_extractor->GetOutput()->GetScalarType(), 1);
im->DeepCopy(m_extractor->GetOutput());
and it works properly. Yet I needed to perform the same operation for a small region defined by origin point p and newsize, from the slice (p.z+z) and modified two lines above (parameter to the SetOutputextent and updateExtent) as follows:
m_slicer->SetOutputExtent(p.x+0, p.x+static_cast<int>(newsize.x) - 1,
p.y+0, p.y+static_cast<int>(newsize.y) - 1,
p.z+z, p.z+z);
const int extent[6] = {p.x+0, p.x+static_cast<int>(newsize.x) - 1,
p.y+0, p.y+static_cast<int>(newsize.y) - 1,
p.z+z, p.z+z};
It returns a small region in the end, yet it is not the proper part of the image defined by p0&newsize. I also used identity transform for testing to be safe. What am I doing wrong here? Thanks!