Mercurial > hg > orthanc-wsi
comparison Applications/Dicomizer.cpp @ 279:77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 12 Jul 2023 18:06:34 +0200 |
parents | 20a730889ae2 |
children | 34b507959e32 b5b9719ef1c0 |
comparison
equal
deleted
inserted
replaced
278:169f168ba07a | 279:77afef2cf64b |
---|---|
641 "URL to the REST API of the target Orthanc server") | 641 "URL to the REST API of the target Orthanc server") |
642 ; | 642 ; |
643 | 643 |
644 boost::program_options::options_description volumeOptions("Description of the imaged volume"); | 644 boost::program_options::options_description volumeOptions("Description of the imaged volume"); |
645 volumeOptions.add_options() | 645 volumeOptions.add_options() |
646 (OPTION_IMAGED_WIDTH, boost::program_options::value<float>()->default_value(15), | 646 (OPTION_IMAGED_WIDTH, boost::program_options::value<float>(), |
647 "Width of the specimen (in mm)") | 647 "Width of the specimen (in mm), defaults to 15mm if missing") |
648 (OPTION_IMAGED_HEIGHT, boost::program_options::value<float>()->default_value(15), | 648 (OPTION_IMAGED_HEIGHT, boost::program_options::value<float>(), |
649 "Height of the specimen (in mm)") | 649 "Height of the specimen (in mm), defaults to 15mm if missing") |
650 (OPTION_IMAGED_DEPTH, boost::program_options::value<float>()->default_value(1), | 650 (OPTION_IMAGED_DEPTH, boost::program_options::value<float>()->default_value(1), |
651 "Depth of the specimen (in mm)") | 651 "Depth of the specimen (in mm)") |
652 (OPTION_OFFSET_X, boost::program_options::value<float>()->default_value(20), | 652 (OPTION_OFFSET_X, boost::program_options::value<float>()->default_value(20), |
653 "X offset the specimen, wrt. slide coordinates origin (in mm)") | 653 "X offset the specimen, wrt. slide coordinates origin (in mm)") |
654 (OPTION_OFFSET_Y, boost::program_options::value<float>()->default_value(40), | 654 (OPTION_OFFSET_Y, boost::program_options::value<float>()->default_value(40), |
1008 } | 1008 } |
1009 | 1009 |
1010 | 1010 |
1011 | 1011 |
1012 OrthancWSI::ITiledPyramid* OpenInputPyramid(OrthancWSI::ImageCompression& sourceCompression, | 1012 OrthancWSI::ITiledPyramid* OpenInputPyramid(OrthancWSI::ImageCompression& sourceCompression, |
1013 OrthancWSI::ImagedVolumeParameters& volume, | |
1013 const std::string& path, | 1014 const std::string& path, |
1014 const OrthancWSI::DicomizerParameters& parameters) | 1015 const OrthancWSI::DicomizerParameters& parameters) |
1015 { | 1016 { |
1016 if (parameters.IsCytomineSource()) | 1017 if (parameters.IsCytomineSource()) |
1017 { | 1018 { |
1070 | 1071 |
1071 try | 1072 try |
1072 { | 1073 { |
1073 LOG(WARNING) << "Trying to open the input pyramid with OpenSlide"; | 1074 LOG(WARNING) << "Trying to open the input pyramid with OpenSlide"; |
1074 sourceCompression = OrthancWSI::ImageCompression_Unknown; | 1075 sourceCompression = OrthancWSI::ImageCompression_Unknown; |
1075 return new OrthancWSI::OpenSlidePyramid(path, | 1076 |
1076 parameters.GetTargetTileWidth(512), | 1077 std::unique_ptr<OrthancWSI::OpenSlidePyramid> openslide( |
1077 parameters.GetTargetTileHeight(512)); | 1078 new OrthancWSI::OpenSlidePyramid(path, parameters.GetTargetTileWidth(512), |
1079 parameters.GetTargetTileHeight(512))); | |
1080 | |
1081 float volumeWidth, volumeHeight; | |
1082 if (openslide->LookupImagedVolumeSize(volumeWidth, volumeHeight)) | |
1083 { | |
1084 if (!volume.HasWidth()) | |
1085 { | |
1086 volume.SetWidth(volumeWidth); | |
1087 } | |
1088 | |
1089 if (!volume.HasHeight()) | |
1090 { | |
1091 volume.SetHeight(volumeHeight); | |
1092 } | |
1093 } | |
1094 | |
1095 return openslide.release(); | |
1078 } | 1096 } |
1079 catch (Orthanc::OrthancException&) | 1097 catch (Orthanc::OrthancException&) |
1080 { | 1098 { |
1081 LOG(ERROR) << "This file is not supported by OpenSlide"; | 1099 LOG(ERROR) << "This file is not supported by OpenSlide"; |
1082 return NULL; | 1100 return NULL; |
1099 if (ParseParameters(exitStatus, parameters, volume, argc, argv)) | 1117 if (ParseParameters(exitStatus, parameters, volume, argc, argv)) |
1100 { | 1118 { |
1101 OrthancWSI::ImageCompression sourceCompression; | 1119 OrthancWSI::ImageCompression sourceCompression; |
1102 std::unique_ptr<OrthancWSI::ITiledPyramid> source; | 1120 std::unique_ptr<OrthancWSI::ITiledPyramid> source; |
1103 | 1121 |
1104 source.reset(OpenInputPyramid(sourceCompression, parameters.GetInputFile(), parameters)); | 1122 source.reset(OpenInputPyramid(sourceCompression, volume, parameters.GetInputFile(), parameters)); |
1105 if (source.get() == NULL) | 1123 if (source.get() == NULL) |
1106 { | 1124 { |
1107 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | 1125 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
1108 } | 1126 } |
1109 | 1127 |