Mercurial > hg > orthanc-wsi
annotate Framework/Inputs/OpenSlidePyramid.cpp @ 312:0683312e21ba
updated copyright, as Orthanc Team now replaces Osimis
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 30 May 2024 22:11:10 +0200 |
parents | 7020852a8fa9 |
children | 072968f00d26 |
rev | line source |
---|---|
0 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
312
0683312e21ba
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
309
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
0683312e21ba
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
309
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
309
7020852a8fa9
updated year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
0 | 8 * |
9 * This program is free software: you can redistribute it and/or | |
10 * modify it under the terms of the GNU Affero General Public License | |
11 * as published by the Free Software Foundation, either version 3 of | |
12 * the License, or (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, but | |
15 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 * Affero General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU Affero General Public License | |
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
23 | |
16
7a88c614be04
preparing for precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
24 #include "../PrecompiledHeadersWSI.h" |
0 | 25 #include "OpenSlidePyramid.h" |
26 | |
199
a1c265cb2174
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
27 #include <Compatibility.h> // For std::unique_ptr |
192 | 28 #include <Images/ImageProcessing.h> |
29 #include <OrthancException.h> | |
279
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
30 #include <SerializationToolbox.h> |
192 | 31 #include <Logging.h> |
140
a0f9a3df1110
resort to Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
115
diff
changeset
|
32 |
a0f9a3df1110
resort to Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
115
diff
changeset
|
33 #include <memory> |
0 | 34 |
35 namespace OrthancWSI | |
36 { | |
37 void OpenSlidePyramid::ReadRegion(Orthanc::ImageAccessor& target, | |
38 unsigned int level, | |
39 unsigned int x, | |
40 unsigned int y) | |
41 { | |
199
a1c265cb2174
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
42 std::unique_ptr<Orthanc::ImageAccessor> source(image_.ReadRegion(level, x, y, target.GetWidth(), target.GetHeight())); |
0 | 43 Orthanc::ImageProcessing::Convert(target, *source); |
44 } | |
45 | |
46 | |
47 OpenSlidePyramid::OpenSlidePyramid(const std::string& path, | |
48 unsigned int tileWidth, | |
49 unsigned int tileHeight) : | |
50 image_(path), | |
51 tileWidth_(tileWidth), | |
52 tileHeight_(tileHeight) | |
53 { | |
54 } | |
279
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
55 |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
56 |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
57 bool OpenSlidePyramid::LookupImagedVolumeSize(float& width, |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
58 float& height) const |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
59 { |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
60 std::string s; |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
61 double mppx; |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
62 double mppy; |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
63 |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
64 if (image_.LookupProperty(s, "openslide.mpp-x") && |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
65 Orthanc::SerializationToolbox::ParseDouble(mppx, s) && |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
66 image_.LookupProperty(s, "openslide.mpp-y") && |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
67 Orthanc::SerializationToolbox::ParseDouble(mppy, s)) |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
68 { |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
69 // In the 2 lines below, remember to switch X/Y when going from physical to pixel coordinates! |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
70 width = mppy / 1000.0 * static_cast<double>(image_.GetLevelHeight(0)); |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
71 height = mppx / 1000.0 * static_cast<double>(image_.GetLevelWidth(0)); |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
72 return true; |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
73 } |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
74 else |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
75 { |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
76 return false; |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
77 } |
77afef2cf64b
automated extraction of the imaged volume if using OpenSlide
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
254
diff
changeset
|
78 } |
0 | 79 } |