Mercurial > hg > orthanc-stone
diff Framework/Radiography/RadiographyScene.cpp @ 1330:a72c2c9af49a
minimal option for GetSceneExtent, especially for masks
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Mon, 30 Mar 2020 09:51:01 +0200 |
parents | d4e6cd35107b |
children | 379c00958553 e0cdf8688d56 |
line wrap: on
line diff
--- a/Framework/Radiography/RadiographyScene.cpp Fri Mar 20 12:52:13 2020 +0100 +++ b/Framework/Radiography/RadiographyScene.cpp Mon Mar 30 09:51:01 2020 +0200 @@ -334,7 +334,7 @@ // modify geometry to reference the top left corner double tlx = centerGeometry->GetPanX(); double tly = centerGeometry->GetPanY(); - Extent2D textExtent = alpha->GetSceneExtent(); + Extent2D textExtent = alpha->GetSceneExtent(false); tlx = tlx - (textExtent.GetWidth() / 2) * centerGeometry->GetPixelSpacingX(); tly = tly - (textExtent.GetHeight() / 2) * centerGeometry->GetPixelSpacingY(); centerGeometry->SetPan(tlx, tly); @@ -543,7 +543,7 @@ } - Extent2D RadiographyScene::GetSceneExtent() const + Extent2D RadiographyScene::GetSceneExtent(bool minimal) const { Extent2D extent; @@ -551,7 +551,7 @@ it != layers_.end(); ++it) { assert(it->second != NULL); - extent.Union(it->second->GetSceneExtent()); + extent.Union(it->second->GetSceneExtent(minimal)); } return extent; @@ -663,9 +663,10 @@ void RadiographyScene::ExtractLayerFromRenderedScene(Orthanc::ImageAccessor& layer, const Orthanc::ImageAccessor& renderedScene, size_t layerIndex, + bool isCropped, ImageInterpolation interpolation) { - Extent2D sceneExtent = GetSceneExtent(); + Extent2D sceneExtent = GetSceneExtent(isCropped); double pixelSpacingX = sceneExtent.GetWidth() / renderedScene.GetWidth(); double pixelSpacingY = sceneExtent.GetHeight() / renderedScene.GetHeight(); @@ -687,6 +688,7 @@ ImageInterpolation interpolation, bool invert, int64_t maxValue /* for inversion */, + bool autoCrop, bool applyWindowing) { if (pixelSpacingX <= 0 || @@ -695,7 +697,7 @@ throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } - Extent2D extent = GetSceneExtent(); + Extent2D extent = GetSceneExtent(autoCrop); int w = boost::math::iround(extent.GetWidth() / pixelSpacingX); int h = boost::math::iround(extent.GetHeight() / pixelSpacingY); @@ -742,11 +744,12 @@ double pixelSpacingX, double pixelSpacingY, bool invert, + bool autoCrop, ImageInterpolation interpolation) { LOG(INFO) << "Exporting RadiographyScene to DICOM"; - std::unique_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 + std::unique_ptr<Orthanc::Image> rendered(ExportToImage(pixelSpacingX, pixelSpacingY, interpolation, autoCrop, false)); // note: we don't invert the image in the pixels data because we'll set the PhotometricDisplayMode correctly in the DICOM tags createDicomRequestContent["Tags"] = dicomTags; @@ -795,13 +798,14 @@ double pixelSpacingX, double pixelSpacingY, bool invert, + bool autoCrop, ImageInterpolation interpolation, bool usePam) { LOG(INFO) << "Exporting RadiographyScene to DICOM"; VLOG(1) << "Exporting RadiographyScene to: export to image"; - std::unique_ptr<Orthanc::Image> rendered(ExportToCreateDicomRequestAndImage(createDicomRequestContent, dicomTags, parentOrthancId, pixelSpacingX, pixelSpacingY, invert, interpolation)); + std::unique_ptr<Orthanc::Image> rendered(ExportToCreateDicomRequestAndImage(createDicomRequestContent, dicomTags, parentOrthancId, pixelSpacingX, pixelSpacingY, invert, autoCrop, interpolation)); // convert the image into base64 for inclusing in the createDicomRequest std::string base64; @@ -840,12 +844,13 @@ double pixelSpacingX, double pixelSpacingY, bool invert, + bool autoCrop, ImageInterpolation interpolation, bool usePam) { Json::Value createDicomRequestContent; - ExportToCreateDicomRequest(createDicomRequestContent, dicomTags, parentOrthancId, pixelSpacingX, pixelSpacingY, invert, interpolation, usePam); + ExportToCreateDicomRequest(createDicomRequestContent, dicomTags, parentOrthancId, pixelSpacingX, pixelSpacingY, invert, autoCrop, interpolation, usePam); orthanc.PostJsonAsyncExpectJson( "/tools/create-dicom", createDicomRequestContent, @@ -864,6 +869,7 @@ double pixelSpacingX, double pixelSpacingY, bool invert, + bool autoCrop, ImageInterpolation interpolation, bool usePam) { @@ -883,7 +889,7 @@ } } - ExportDicom(orthanc, jsonTags, parentOrthancId, pixelSpacingX, pixelSpacingY, invert, interpolation, usePam); + ExportDicom(orthanc, jsonTags, parentOrthancId, pixelSpacingX, pixelSpacingY, invert, autoCrop, interpolation, usePam); } void RadiographyScene::OnDicomExported(const Deprecated::OrthancApiClient::JsonResponseReadyMessage& message)