132 typedef TImage ImageType;
133 typedef typename ImageType::Pointer ImagePointer;
134 typedef typename ImageType::PixelType PixelType;
135 typedef typename ImageType::PointType PointType;
136 typedef typename ImageType::SpacingType SpacingType;
137 typedef typename ImageType::RegionType RegionType;
138 typedef typename ImageType::IndexType IndexType;
139 typedef typename ImageType::SizeType SizeType;
141 PointType origin = input->GetOrigin();
142 SpacingType spacing = input->GetSpacing();
144 double outputOrigin[3];
145 double outputSpacing[3];
147 outputOrigin[0] = origin[0];
148 outputOrigin[1] = origin[1];
149 outputOrigin[2] = origin[2];
151 outputSpacing[0] = spacing[0];
152 outputSpacing[1] = spacing[1];
153 outputSpacing[2] = spacing[2];
155 output->SetOrigin(outputOrigin);
156 output->SetSpacing(outputSpacing);
158 RegionType region = input->GetBufferedRegion();
159 IndexType index = region.GetIndex();
160 SizeType size = region.GetSize();
167 extent[0] = index[0];
168 extent[1] = index[0] + size[0] - 1;
169 extent[2] = index[1];
170 extent[3] = index[1] + size[1] - 1;
171 extent[4] = index[2];
172 extent[5] = index[2] + size[2] - 1;
174 int components = input->GetNumberOfComponentsPerPixel();
175 int dataType = output->GetScalarType();
178 output->SetExtent(extent);
179 output->AllocateScalars(dataType,components);
181 memcpy(static_cast<PixelType*>(output->GetScalarPointer()),input->GetBufferPointer(),input->GetBufferedRegion().GetNumberOfPixels()*
sizeof(PixelType));