Mercurial > hg > orthanc-stone
comparison Framework/Radiography/RadiographyScene.cpp @ 1196:a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Wed, 27 Nov 2019 17:51:33 +0100 |
parents | f417a0ae282b |
children | 922d2e61aa5d |
comparison
equal
deleted
inserted
replaced
1191:c6a36ecd641d | 1196:a5f2a6b04a31 |
---|---|
281 BroadcastMessage(RadiographyScene::WindowingChangedMessage(*this)); | 281 BroadcastMessage(RadiographyScene::WindowingChangedMessage(*this)); |
282 } | 282 } |
283 | 283 |
284 | 284 |
285 RadiographyLayer& RadiographyScene::LoadText(const std::string& utf8, | 285 RadiographyLayer& RadiographyScene::LoadText(const std::string& utf8, |
286 size_t fontSize, | 286 unsigned int fontSize, |
287 uint8_t foreground, | 287 uint8_t foreground, |
288 RadiographyLayer::Geometry* geometry) | 288 RadiographyLayer::Geometry* geometry) |
289 { | 289 { |
290 std::auto_ptr<RadiographyTextLayer> alpha(new RadiographyTextLayer(IObservable::GetBroker(), *this)); | 290 std::auto_ptr<RadiographyTextLayer> alpha(new RadiographyTextLayer(IObservable::GetBroker(), *this)); |
291 alpha->LoadText(utf8, fontSize, foreground); | 291 alpha->LoadText(utf8, fontSize, foreground); |
507 } | 507 } |
508 | 508 |
509 | 509 |
510 void RadiographyScene::Render(Orthanc::ImageAccessor& buffer, | 510 void RadiographyScene::Render(Orthanc::ImageAccessor& buffer, |
511 const AffineTransform2D& viewTransform, | 511 const AffineTransform2D& viewTransform, |
512 ImageInterpolation interpolation) const | 512 ImageInterpolation interpolation, |
513 bool applyWindowing) const | |
513 { | 514 { |
514 // Render layers in the background-to-foreground order | 515 // Render layers in the background-to-foreground order |
515 for (size_t index = 0; index < countLayers_; index++) | 516 for (size_t index = 0; index < countLayers_; index++) |
516 { | 517 { |
517 Layers::const_iterator it = layers_.find(index); | 518 Layers::const_iterator it = layers_.find(index); |
518 if (it != layers_.end()) | 519 if (it != layers_.end()) |
519 { | 520 { |
520 assert(it->second != NULL); | 521 assert(it->second != NULL); |
521 it->second->Render(buffer, viewTransform, interpolation); | 522 it->second->Render(buffer, viewTransform, interpolation, windowingCenter_, windowingWidth_, applyWindowing); |
522 } | 523 } |
523 } | 524 } |
524 } | 525 } |
525 | 526 |
526 | 527 |
597 | 598 |
598 Orthanc::Image* RadiographyScene::ExportToImage(double pixelSpacingX, | 599 Orthanc::Image* RadiographyScene::ExportToImage(double pixelSpacingX, |
599 double pixelSpacingY, | 600 double pixelSpacingY, |
600 ImageInterpolation interpolation, | 601 ImageInterpolation interpolation, |
601 bool invert, | 602 bool invert, |
602 int64_t maxValue /* for inversion */) | 603 int64_t maxValue /* for inversion */, |
604 bool applyWindowing) | |
603 { | 605 { |
604 if (pixelSpacingX <= 0 || | 606 if (pixelSpacingX <= 0 || |
605 pixelSpacingY <= 0) | 607 pixelSpacingY <= 0) |
606 { | 608 { |
607 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 609 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
626 AffineTransform2D::CreateOffset(-extent.GetX1(), -extent.GetY1())); | 628 AffineTransform2D::CreateOffset(-extent.GetX1(), -extent.GetY1())); |
627 | 629 |
628 // wipe background before rendering | 630 // wipe background before rendering |
629 Orthanc::ImageProcessing::Set(layers, 0); | 631 Orthanc::ImageProcessing::Set(layers, 0); |
630 | 632 |
631 Render(layers, view, interpolation); | 633 Render(layers, view, interpolation, applyWindowing); |
632 | 634 |
633 std::auto_ptr<Orthanc::Image> rendered(new Orthanc::Image(Orthanc::PixelFormat_Grayscale16, | 635 std::auto_ptr<Orthanc::Image> rendered(new Orthanc::Image(Orthanc::PixelFormat_Grayscale16, |
634 layers.GetWidth(), layers.GetHeight(), false)); | 636 layers.GetWidth(), layers.GetHeight(), false)); |
635 | 637 |
636 Orthanc::ImageProcessing::Convert(*rendered, layers); | 638 Orthanc::ImageProcessing::Convert(*rendered, layers); |
649 bool invert, | 651 bool invert, |
650 ImageInterpolation interpolation) | 652 ImageInterpolation interpolation) |
651 { | 653 { |
652 LOG(INFO) << "Exporting RadiographyScene to DICOM"; | 654 LOG(INFO) << "Exporting RadiographyScene to DICOM"; |
653 | 655 |
654 std::auto_ptr<Orthanc::Image> rendered(ExportToImage(pixelSpacingX, pixelSpacingY, interpolation)); // note: we don't invert the image in the pixels data because we'll set the PhotometricDisplayMode correctly in the DICOM tags | 656 std::auto_ptr<Orthanc::Image> rendered(ExportToImage(pixelSpacingX, pixelSpacingY, interpolation, false)); // note: we don't invert the image in the pixels data because we'll set the PhotometricDisplayMode correctly in the DICOM tags |
655 | 657 |
656 createDicomRequestContent["Tags"] = dicomTags; | 658 createDicomRequestContent["Tags"] = dicomTags; |
657 | 659 |
658 RadiographyPhotometricDisplayMode photometricMode = GetPreferredPhotomotricDisplayMode(); | 660 RadiographyPhotometricDisplayMode photometricMode = GetPreferredPhotomotricDisplayMode(); |
659 if ((invert && photometricMode != RadiographyPhotometricDisplayMode_Monochrome2) || | 661 if ((invert && photometricMode != RadiographyPhotometricDisplayMode_Monochrome2) || |