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

removing dependencies in ImageBuffer3D
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 21 May 2019 16:15:06 +0200
parents 9a474e90e832
children ffec76a5f7eb
comparison
equal deleted inserted replaced
734:be3671662eec 735:c3bbb130abc4
21 21
22 #include "FiniteProjectiveCamera.h" 22 #include "FiniteProjectiveCamera.h"
23 23
24 #include "GeometryToolbox.h" 24 #include "GeometryToolbox.h"
25 #include "SubpixelReader.h" 25 #include "SubpixelReader.h"
26 #include "ParallelSlices.h"
26 27
27 #include <Core/Logging.h> 28 #include <Core/Logging.h>
28 #include <Core/OrthancException.h> 29 #include <Core/OrthancException.h>
29 #include <Core/Images/Image.h> 30 #include <Core/Images/Image.h>
30 #include <Core/Images/ImageProcessing.h> 31 #include <Core/Images/ImageProcessing.h>
297 Orthanc::PixelFormat SourceFormat, 298 Orthanc::PixelFormat SourceFormat,
298 bool MIP> 299 bool MIP>
299 static void ApplyRaytracerInternal(Orthanc::ImageAccessor& target, 300 static void ApplyRaytracerInternal(Orthanc::ImageAccessor& target,
300 const FiniteProjectiveCamera& camera, 301 const FiniteProjectiveCamera& camera,
301 const ImageBuffer3D& source, 302 const ImageBuffer3D& source,
303 const VolumeImageGeometry& geometry,
302 VolumeProjection projection) 304 VolumeProjection projection)
303 { 305 {
304 if (source.GetFormat() != SourceFormat || 306 if (source.GetFormat() != SourceFormat ||
305 target.GetFormat() != TargetFormat || 307 target.GetFormat() != TargetFormat ||
306 !std::numeric_limits<float>::is_iec559 || 308 !std::numeric_limits<float>::is_iec559 ||
313 << source.GetHeight() << "x" << source.GetDepth(); 315 << source.GetHeight() << "x" << source.GetDepth();
314 LOG(WARNING) << "Input pixel format: " << Orthanc::EnumerationToString(source.GetFormat()); 316 LOG(WARNING) << "Input pixel format: " << Orthanc::EnumerationToString(source.GetFormat());
315 LOG(WARNING) << "Output image size: " << target.GetWidth() << "x" << target.GetHeight(); 317 LOG(WARNING) << "Output image size: " << target.GetWidth() << "x" << target.GetHeight();
316 LOG(WARNING) << "Output pixel format: " << Orthanc::EnumerationToString(target.GetFormat()); 318 LOG(WARNING) << "Output pixel format: " << Orthanc::EnumerationToString(target.GetFormat());
317 319
318 std::auto_ptr<OrthancStone::ParallelSlices> slices(source.GetGeometry(projection)); 320 std::auto_ptr<OrthancStone::ParallelSlices> slices(OrthancStone::ParallelSlices::FromVolumeImage(geometry, projection));
319 const OrthancStone::Vector pixelSpacing = source.GetGeometry().GetVoxelDimensions(projection); 321 const OrthancStone::Vector pixelSpacing = geometry.GetVoxelDimensions(projection);
320 const unsigned int targetWidth = target.GetWidth(); 322 const unsigned int targetWidth = target.GetWidth();
321 const unsigned int targetHeight = target.GetHeight(); 323 const unsigned int targetHeight = target.GetHeight();
322 324
323 Orthanc::Image accumulator(Orthanc::PixelFormat_Float32, targetWidth, targetHeight, false); 325 Orthanc::Image accumulator(Orthanc::PixelFormat_Float32, targetWidth, targetHeight, false);
324 Orthanc::Image counter(Orthanc::PixelFormat_Grayscale16, targetWidth, targetHeight, false); 326 Orthanc::Image counter(Orthanc::PixelFormat_Grayscale16, targetWidth, targetHeight, false);
420 } 422 }
421 423
422 424
423 Orthanc::ImageAccessor* 425 Orthanc::ImageAccessor*
424 FiniteProjectiveCamera::ApplyRaytracer(const ImageBuffer3D& source, 426 FiniteProjectiveCamera::ApplyRaytracer(const ImageBuffer3D& source,
427 const VolumeImageGeometry& geometry,
425 Orthanc::PixelFormat targetFormat, 428 Orthanc::PixelFormat targetFormat,
426 unsigned int targetWidth, 429 unsigned int targetWidth,
427 unsigned int targetHeight, 430 unsigned int targetHeight,
428 bool mip) const 431 bool mip) const
429 { 432 {
438 if (targetFormat == Orthanc::PixelFormat_Grayscale16 && 441 if (targetFormat == Orthanc::PixelFormat_Grayscale16 &&
439 source.GetFormat() == Orthanc::PixelFormat_Grayscale16 && mip) 442 source.GetFormat() == Orthanc::PixelFormat_Grayscale16 && mip)
440 { 443 {
441 ApplyRaytracerInternal<Orthanc::PixelFormat_Grayscale16, 444 ApplyRaytracerInternal<Orthanc::PixelFormat_Grayscale16,
442 Orthanc::PixelFormat_Grayscale16, true> 445 Orthanc::PixelFormat_Grayscale16, true>
443 (*target, *this, source, projection); 446 (*target, *this, source, geometry, projection);
444 } 447 }
445 else if (targetFormat == Orthanc::PixelFormat_Grayscale16 && 448 else if (targetFormat == Orthanc::PixelFormat_Grayscale16 &&
446 source.GetFormat() == Orthanc::PixelFormat_Grayscale16 && !mip) 449 source.GetFormat() == Orthanc::PixelFormat_Grayscale16 && !mip)
447 { 450 {
448 ApplyRaytracerInternal<Orthanc::PixelFormat_Grayscale16, 451 ApplyRaytracerInternal<Orthanc::PixelFormat_Grayscale16,
449 Orthanc::PixelFormat_Grayscale16, false> 452 Orthanc::PixelFormat_Grayscale16, false>
450 (*target, *this, source, projection); 453 (*target, *this, source, geometry, projection);
451 } 454 }
452 else 455 else
453 { 456 {
454 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); 457 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
455 } 458 }