MCPcopy Create free account
hub / github.com/SimVascular/SimVascular / ResliceImage

Function ResliceImage

Code/Source/PythonAPI/ImagingImage_PyClass.cxx:284–317  ·  view source on GitHub ↗

-------------- ResliceImage -------------- Note: This is taken from sv4guiSegmentationUtils::GetSlicevtkImage() but does not work here, slice is off.

Source from the content-addressed store, hash-verified

282// but does not work here, slice is off.
283//
284vtkImageData *
285ResliceImage(mitk::Image* image, double planeSize, double pos[3], double tangent[3], double rotation[3])
286{
287 vtkTransform* tr = GetvtkTransform(pos, tangent, rotation);
288 vtkImageReslice* rs = vtkImageReslice::New();
289
290 auto vtkImage = image->GetVtkImageData();
291 double spacing[3];
292 vtkImage->GetSpacing(spacing);
293
294 // This does not make sense, just need std::min(spacing[0],spacing[1]).
295 double vmin = std::min(spacing[0], std::min(spacing[0],spacing[1]));
296
297 int width = planeSize / vmin;
298 int height = planeSize / vmin;
299 double pdimx = width * vmin;
300 double pdimy = height * vmin;
301
302 double origin[3];
303 origin[0] = -0.5 * pdimx;
304 origin[1] = -0.5 * pdimy;
305 origin[2] = 0.0;
306
307 rs->SetInputDataObject(vtkImage);
308
309 rs->SetResliceTransform(tr);
310 rs->SetOutputSpacing(vmin,vmin,vmin);
311 rs->SetOutputOrigin(origin);
312 rs->SetOutputExtent(0, width-1, 0, height-1, 0, 0);
313 rs->InterpolateOn();
314 rs->Update();
315
316 return rs->GetOutput();
317}
318
319//------------
320// ScaleImage

Callers

nothing calls this directly

Calls 3

GetvtkTransformFunction · 0.85
GetSpacingMethod · 0.45
UpdateMethod · 0.45

Tested by

no test coverage detected