comparison Framework/Toolbox/ShearWarpProjectiveTransform.cpp @ 735:c3bbb130abc4

removing dependencies in ImageBuffer3D
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 21 May 2019 16:15:06 +0200
parents f45fca2ebd10
children 2d8ab34c8c91
comparison
equal deleted inserted replaced
734:be3671662eec 735:c3bbb130abc4
341 bool MIP> 341 bool MIP>
342 static void ApplyAxialInternal(Orthanc::ImageAccessor& target, 342 static void ApplyAxialInternal(Orthanc::ImageAccessor& target,
343 float& maxValue, 343 float& maxValue,
344 const Matrix& M_view, 344 const Matrix& M_view,
345 const ImageBuffer3D& source, 345 const ImageBuffer3D& source,
346 const VolumeImageGeometry& geometry,
346 double pixelSpacing, 347 double pixelSpacing,
347 unsigned int countSlices, 348 unsigned int countSlices,
348 ImageInterpolation shearInterpolation, 349 ImageInterpolation shearInterpolation,
349 ImageInterpolation warpInterpolation) 350 ImageInterpolation warpInterpolation)
350 { 351 {
383 * M_view. 384 * M_view.
384 **/ 385 **/
385 386
386 // Compute the "world" matrix that maps the source volume to the 387 // Compute the "world" matrix that maps the source volume to the
387 // (0,0,0)->(1,1,1) unit cube 388 // (0,0,0)->(1,1,1) unit cube
388 Vector origin = source.GetGeometry().GetCoordinates(0, 0, 0); 389 Vector origin = geometry.GetCoordinates(0, 0, 0);
389 Vector ps = source.GetGeometry().GetVoxelDimensions(VolumeProjection_Axial); 390 Vector ps = geometry.GetVoxelDimensions(VolumeProjection_Axial);
390 Matrix world = LinearAlgebra::Product( 391 Matrix world = LinearAlgebra::Product(
391 GeometryToolbox::CreateScalingMatrix(1.0 / ps[0], 1.0 / ps[1], 1.0 / ps[2]), 392 GeometryToolbox::CreateScalingMatrix(1.0 / ps[0], 1.0 / ps[1], 1.0 / ps[2]),
392 GeometryToolbox::CreateTranslationMatrix(-origin[0], -origin[1], -origin[2])); 393 GeometryToolbox::CreateTranslationMatrix(-origin[0], -origin[1], -origin[2]));
393 394
394 Matrix worldInv; 395 Matrix worldInv;
596 Orthanc::PixelFormat TargetFormat> 597 Orthanc::PixelFormat TargetFormat>
597 static void ApplyAxialInternal2(Orthanc::ImageAccessor& target, 598 static void ApplyAxialInternal2(Orthanc::ImageAccessor& target,
598 float& maxValue, 599 float& maxValue,
599 const Matrix& M_view, 600 const Matrix& M_view,
600 const ImageBuffer3D& source, 601 const ImageBuffer3D& source,
602 const VolumeImageGeometry& geometry,
601 bool mip, 603 bool mip,
602 double pixelSpacing, 604 double pixelSpacing,
603 unsigned int countSlices, 605 unsigned int countSlices,
604 ImageInterpolation shearInterpolation, 606 ImageInterpolation shearInterpolation,
605 ImageInterpolation warpInterpolation) 607 ImageInterpolation warpInterpolation)
606 { 608 {
607 if (mip) 609 if (mip)
608 { 610 {
609 ApplyAxialInternal<SourceFormat, TargetFormat, true> 611 ApplyAxialInternal<SourceFormat, TargetFormat, true>
610 (target, maxValue, M_view, source, pixelSpacing, 612 (target, maxValue, M_view, source, geometry, pixelSpacing,
611 countSlices, shearInterpolation, warpInterpolation); 613 countSlices, shearInterpolation, warpInterpolation);
612 } 614 }
613 else 615 else
614 { 616 {
615 ApplyAxialInternal<SourceFormat, TargetFormat, false> 617 ApplyAxialInternal<SourceFormat, TargetFormat, false>
616 (target, maxValue, M_view, source, pixelSpacing, 618 (target, maxValue, M_view, source, geometry, pixelSpacing,
617 countSlices, shearInterpolation, warpInterpolation); 619 countSlices, shearInterpolation, warpInterpolation);
618 } 620 }
619 } 621 }
620 622
621 623
622 Orthanc::ImageAccessor* 624 Orthanc::ImageAccessor*
623 ShearWarpProjectiveTransform::ApplyAxial(float& maxValue, 625 ShearWarpProjectiveTransform::ApplyAxial(float& maxValue,
624 const Matrix& M_view, 626 const Matrix& M_view,
625 const ImageBuffer3D& source, 627 const ImageBuffer3D& source,
628 const VolumeImageGeometry& geometry,
626 Orthanc::PixelFormat targetFormat, 629 Orthanc::PixelFormat targetFormat,
627 unsigned int targetWidth, 630 unsigned int targetWidth,
628 unsigned int targetHeight, 631 unsigned int targetHeight,
629 bool mip, 632 bool mip,
630 double pixelSpacing, 633 double pixelSpacing,
638 if (source.GetFormat() == Orthanc::PixelFormat_Grayscale16 && 641 if (source.GetFormat() == Orthanc::PixelFormat_Grayscale16 &&
639 targetFormat == Orthanc::PixelFormat_Grayscale16) 642 targetFormat == Orthanc::PixelFormat_Grayscale16)
640 { 643 {
641 ApplyAxialInternal2<Orthanc::PixelFormat_Grayscale16, 644 ApplyAxialInternal2<Orthanc::PixelFormat_Grayscale16,
642 Orthanc::PixelFormat_Grayscale16> 645 Orthanc::PixelFormat_Grayscale16>
643 (*target, maxValue, M_view, source, mip, pixelSpacing, 646 (*target, maxValue, M_view, source, geometry, mip, pixelSpacing,
644 countSlices, shearInterpolation, warpInterpolation); 647 countSlices, shearInterpolation, warpInterpolation);
645 } 648 }
646 else if (source.GetFormat() == Orthanc::PixelFormat_SignedGrayscale16 && 649 else if (source.GetFormat() == Orthanc::PixelFormat_SignedGrayscale16 &&
647 targetFormat == Orthanc::PixelFormat_SignedGrayscale16) 650 targetFormat == Orthanc::PixelFormat_SignedGrayscale16)
648 { 651 {
649 ApplyAxialInternal2<Orthanc::PixelFormat_SignedGrayscale16, 652 ApplyAxialInternal2<Orthanc::PixelFormat_SignedGrayscale16,
650 Orthanc::PixelFormat_SignedGrayscale16> 653 Orthanc::PixelFormat_SignedGrayscale16>
651 (*target, maxValue, M_view, source, mip, pixelSpacing, 654 (*target, maxValue, M_view, source, geometry, mip, pixelSpacing,
652 countSlices, shearInterpolation, warpInterpolation); 655 countSlices, shearInterpolation, warpInterpolation);
653 } 656 }
654 else 657 else
655 { 658 {
656 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); 659 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);