comparison Framework/Inputs/OpenSlidePyramid.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 7020852a8fa9
comparison
equal deleted inserted replaced
278:169f168ba07a 279:77afef2cf64b
24 #include "OpenSlidePyramid.h" 24 #include "OpenSlidePyramid.h"
25 25
26 #include <Compatibility.h> // For std::unique_ptr 26 #include <Compatibility.h> // For std::unique_ptr
27 #include <Images/ImageProcessing.h> 27 #include <Images/ImageProcessing.h>
28 #include <OrthancException.h> 28 #include <OrthancException.h>
29 #include <SerializationToolbox.h>
29 #include <Logging.h> 30 #include <Logging.h>
30 31
31 #include <memory> 32 #include <memory>
32 33
33 namespace OrthancWSI 34 namespace OrthancWSI
48 image_(path), 49 image_(path),
49 tileWidth_(tileWidth), 50 tileWidth_(tileWidth),
50 tileHeight_(tileHeight) 51 tileHeight_(tileHeight)
51 { 52 {
52 } 53 }
54
55
56 bool OpenSlidePyramid::LookupImagedVolumeSize(float& width,
57 float& height) const
58 {
59 std::string s;
60 double mppx;
61 double mppy;
62
63 if (image_.LookupProperty(s, "openslide.mpp-x") &&
64 Orthanc::SerializationToolbox::ParseDouble(mppx, s) &&
65 image_.LookupProperty(s, "openslide.mpp-y") &&
66 Orthanc::SerializationToolbox::ParseDouble(mppy, s))
67 {
68 // In the 2 lines below, remember to switch X/Y when going from physical to pixel coordinates!
69 width = mppy / 1000.0 * static_cast<double>(image_.GetLevelHeight(0));
70 height = mppx / 1000.0 * static_cast<double>(image_.GetLevelWidth(0));
71 return true;
72 }
73 else
74 {
75 return false;
76 }
77 }
53 } 78 }