annotate OrthancStone/Sources/Volumes/ImageBuffer3D.cpp @ 1652:fa9e6bf84958

integrating pdf.js into Stone Web viewer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 16 Nov 2020 20:47:53 +0100
parents 8563ea5d8ae4
children 9ac2a65d4172
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1270
2d8ab34c8c91 upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1105
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1564
diff changeset
8 * modify it under the terms of the GNU Lesser General Public License
47
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
10 * the License, or (at your option) any later version.
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1564
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1564
diff changeset
15 * Lesser General Public License for more details.
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
16 *
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1564
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1564
diff changeset
18 * License along with this program. If not, see
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1564
diff changeset
19 * <http://www.gnu.org/licenses/>.
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include "ImageBuffer3D.h"
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1298
diff changeset
25 #include <Images/ImageProcessing.h>
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1298
diff changeset
26 #include <Logging.h>
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1298
diff changeset
27 #include <OrthancException.h>
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
87
4a541cd4fa83 OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
29 #include <string.h>
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 namespace OrthancStone
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
316
ce48c3b3b0e9 fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
33 void ImageBuffer3D::GetAxialSliceAccessor(Orthanc::ImageAccessor& target,
ce48c3b3b0e9 fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
34 unsigned int slice,
1564
e731e62692a9 upgrading Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
35 bool readOnly)
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 if (slice >= depth_)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 if (readOnly)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 {
316
ce48c3b3b0e9 fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
44 target.AssignReadOnly(format_, width_, height_, image_.GetPitch(),
ce48c3b3b0e9 fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
45 image_.GetConstRow(height_ * (depth_ - 1 - slice)));
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 else
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
316
ce48c3b3b0e9 fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
49 target.AssignWritable(format_, width_, height_, image_.GetPitch(),
ce48c3b3b0e9 fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
50 image_.GetRow(height_ * (depth_ - 1 - slice)));
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
316
ce48c3b3b0e9 fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
55 void ImageBuffer3D::GetCoronalSliceAccessor(Orthanc::ImageAccessor& target,
ce48c3b3b0e9 fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
56 unsigned int slice,
1564
e731e62692a9 upgrading Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
57 bool readOnly)
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 if (slice >= height_)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 if (readOnly)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 {
316
ce48c3b3b0e9 fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
66 target.AssignReadOnly(format_, width_, depth_, image_.GetPitch() * height_,
ce48c3b3b0e9 fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
67 image_.GetConstRow(slice));
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 else
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 {
316
ce48c3b3b0e9 fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
71 target.AssignWritable(format_, width_, depth_, image_.GetPitch() * height_,
ce48c3b3b0e9 fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
72 image_.GetRow(slice));
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 Orthanc::Image* ImageBuffer3D::ExtractSagittalSlice(unsigned int slice) const
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 {
949
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 735
diff changeset
79 //LOG(TRACE) << "ImageBuffer3D::ExtractSagittalSlice this= " << std::hex << this << std::dec << " width_ = " << width_ << " height_ = " << height_ << " depth_ = " << depth_ << " slice = " << slice;
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 if (slice >= width_)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
85 std::unique_ptr<Orthanc::Image> result(new Orthanc::Image(format_, height_, depth_, false));
949
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 735
diff changeset
86 //LOG(TRACE) << "ImageBuffer3D::ExtractSagittalSlice result will be an image of WIDTH = " << height_ << " and HEIGHT = " << depth_;
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 unsigned int bytesPerPixel = Orthanc::GetBytesPerPixel(format_);
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 for (unsigned int z = 0; z < depth_; z++)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 //uint8_t* target = reinterpret_cast<uint8_t*>(result->GetRow(depth_ - 1 - z));
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 uint8_t* target = reinterpret_cast<uint8_t*>(result->GetRow(z));
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 for (unsigned int y = 0; y < height_; y++)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 {
949
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 735
diff changeset
97 const void* source = (reinterpret_cast<const uint8_t*>(image_.GetConstRow(y + z * height_)) + bytesPerPixel * slice);
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 735
diff changeset
98 const uint8_t* byteSrc = reinterpret_cast<const uint8_t*>(source);
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 735
diff changeset
99 for (size_t byte = 0; byte < bytesPerPixel; ++byte)
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 735
diff changeset
100 target[byte] = byteSrc[byte];
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 target += bytesPerPixel;
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 return result.release();
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 ImageBuffer3D::ImageBuffer3D(Orthanc::PixelFormat format,
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 unsigned int width,
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 unsigned int height,
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
112 unsigned int depth,
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
113 bool computeRange) :
11
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
114 image_(format, width, height * depth, false),
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 format_(format),
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 width_(width),
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 height_(height),
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
118 depth_(depth),
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
119 computeRange_(computeRange),
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
120 hasRange_(false)
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 {
1105
640feb146fa8 Code formatting (dummyc) + log level (dummyc)
Benjamin Golinvaux <bgo@osimis.io>
parents: 949
diff changeset
122 LOG(TRACE) << "Created a 3D image of size " << width << "x" << height
667
e9339f2b5de7 refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
123 << "x" << depth << " in " << Orthanc::EnumerationToString(format)
e9339f2b5de7 refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
124 << " (" << (GetEstimatedMemorySize() / (1024ll * 1024ll)) << "MB)";
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 void ImageBuffer3D::Clear()
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 {
87
4a541cd4fa83 OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
130 memset(image_.GetBuffer(), 0, image_.GetHeight() * image_.GetPitch());
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133
105
e0ddd8cad909 cleaning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
134 uint64_t ImageBuffer3D::GetEstimatedMemorySize() const
e0ddd8cad909 cleaning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
135 {
e0ddd8cad909 cleaning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
136 return image_.GetPitch() * image_.GetHeight() * Orthanc::GetBytesPerPixel(format_);
e0ddd8cad909 cleaning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
137 }
e0ddd8cad909 cleaning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
138
e0ddd8cad909 cleaning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
139
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
140 void ImageBuffer3D::ExtendImageRange(const Orthanc::ImageAccessor& slice)
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
141 {
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
142 if (!computeRange_ ||
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
143 slice.GetWidth() == 0 ||
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
144 slice.GetHeight() == 0)
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
145 {
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
146 return;
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
147 }
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
148
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
149 float sliceMin, sliceMax;
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
150
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
151 switch (slice.GetFormat())
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
152 {
684
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
153 case Orthanc::PixelFormat_Grayscale8:
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
154 case Orthanc::PixelFormat_Grayscale16:
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
155 case Orthanc::PixelFormat_Grayscale32:
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
156 case Orthanc::PixelFormat_SignedGrayscale16:
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
157 {
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
158 int64_t a, b;
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
159 Orthanc::ImageProcessing::GetMinMaxIntegerValue(a, b, slice);
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
160 sliceMin = static_cast<float>(a);
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
161 sliceMax = static_cast<float>(b);
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
162 break;
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
163 }
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
164
684
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
165 case Orthanc::PixelFormat_Float32:
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
166 Orthanc::ImageProcessing::GetMinMaxFloatValue(sliceMin, sliceMax, slice);
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
167 break;
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
168
684
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
169 default:
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
170 return;
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
171 }
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
172
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
173 if (hasRange_)
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
174 {
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
175 minValue_ = std::min(minValue_, sliceMin);
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
176 maxValue_ = std::max(maxValue_, sliceMax);
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
177 }
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
178 else
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
179 {
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
180 hasRange_ = true;
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
181 minValue_ = sliceMin;
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
182 maxValue_ = sliceMax;
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
183 }
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
184 }
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
185
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
186
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
187 bool ImageBuffer3D::GetRange(float& minValue,
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
188 float& maxValue) const
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
189 {
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
190 if (hasRange_)
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
191 {
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
192 minValue = minValue_;
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
193 maxValue = maxValue_;
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
194 return true;
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
195 }
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
196 else
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
197 {
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
198 return false;
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
199 }
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
200 }
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
201
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
202
192
371da7fe2c0e FiniteProjectiveCamera::ApplyRaytracer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
203 ImageBuffer3D::SliceReader::SliceReader(const ImageBuffer3D& that,
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 VolumeProjection projection,
87
4a541cd4fa83 OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
205 unsigned int slice)
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 {
1564
e731e62692a9 upgrading Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
207 /**
e731e62692a9 upgrading Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
208 * NB: The "const_cast" below are OK, as the "readonly" argument
e731e62692a9 upgrading Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
209 * to "GetAxialSliceAccessor()" and "GetCoronalSliceAccessor()"
e731e62692a9 upgrading Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
210 * are set to "true", which implies read-only access.
e731e62692a9 upgrading Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
211 **/
e731e62692a9 upgrading Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
212
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 switch (projection)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 case VolumeProjection_Axial:
1564
e731e62692a9 upgrading Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
216 const_cast<ImageBuffer3D&>(that).GetAxialSliceAccessor(accessor_, slice, true);
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 break;
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 case VolumeProjection_Coronal:
1564
e731e62692a9 upgrading Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
220 const_cast<ImageBuffer3D&>(that).GetCoronalSliceAccessor(accessor_, slice, true);
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 break;
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 case VolumeProjection_Sagittal:
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 sagittal_.reset(that.ExtractSagittalSlice(slice));
316
ce48c3b3b0e9 fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
225 sagittal_->GetReadOnlyAccessor(accessor_);
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 break;
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227
684
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
228 default:
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
229 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 void ImageBuffer3D::SliceWriter::Flush()
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 {
87
4a541cd4fa83 OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
236 if (modified_)
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 {
87
4a541cd4fa83 OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
238 if (sagittal_.get() != NULL)
4a541cd4fa83 OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
239 {
4a541cd4fa83 OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
240 // TODO
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
241 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
87
4a541cd4fa83 OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
242 }
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
243
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
244 // Update the dynamic range of the underlying image, if
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
245 // "computeRange_" is set to true
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
246 that_.ExtendImageRange(accessor_);
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 ImageBuffer3D::SliceWriter::SliceWriter(ImageBuffer3D& that,
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 VolumeProjection projection,
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 unsigned int slice) :
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
254 that_(that),
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
255 modified_(false)
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 switch (projection)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 case VolumeProjection_Axial:
316
ce48c3b3b0e9 fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
260 that.GetAxialSliceAccessor(accessor_, slice, false);
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 break;
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 case VolumeProjection_Coronal:
316
ce48c3b3b0e9 fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
264 that.GetCoronalSliceAccessor(accessor_, slice, false);
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 break;
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 case VolumeProjection_Sagittal:
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 sagittal_.reset(that.ExtractSagittalSlice(slice));
316
ce48c3b3b0e9 fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
269 sagittal_->GetWriteableAccessor(accessor_);
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 break;
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271
684
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
272 default:
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
273 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 }
139
22628d37ef5c ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
276
22628d37ef5c ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
277
143
58c545177c1c optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 141
diff changeset
278 uint8_t ImageBuffer3D::GetVoxelGrayscale8(unsigned int x,
141
88bca952cb17 ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 139
diff changeset
279 unsigned int y,
88bca952cb17 ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 139
diff changeset
280 unsigned int z) const
88bca952cb17 ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 139
diff changeset
281 {
88bca952cb17 ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 139
diff changeset
282 if (format_ != Orthanc::PixelFormat_Grayscale8)
88bca952cb17 ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 139
diff changeset
283 {
88bca952cb17 ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 139
diff changeset
284 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
88bca952cb17 ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 139
diff changeset
285 }
88bca952cb17 ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 139
diff changeset
286
88bca952cb17 ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 139
diff changeset
287 if (x >= width_ ||
88bca952cb17 ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 139
diff changeset
288 y >= height_ ||
88bca952cb17 ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 139
diff changeset
289 z >= depth_)
88bca952cb17 ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 139
diff changeset
290 {
88bca952cb17 ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 139
diff changeset
291 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
88bca952cb17 ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 139
diff changeset
292 }
88bca952cb17 ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 139
diff changeset
293
88bca952cb17 ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 139
diff changeset
294 const void* p = image_.GetConstRow(y + height_ * (depth_ - 1 - z));
88bca952cb17 ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 139
diff changeset
295 return reinterpret_cast<const uint8_t*>(p) [x];
88bca952cb17 ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 139
diff changeset
296 }
88bca952cb17 ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 139
diff changeset
297
88bca952cb17 ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 139
diff changeset
298
143
58c545177c1c optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 141
diff changeset
299 uint16_t ImageBuffer3D::GetVoxelGrayscale16(unsigned int x,
139
22628d37ef5c ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
300 unsigned int y,
22628d37ef5c ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
301 unsigned int z) const
22628d37ef5c ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
302 {
22628d37ef5c ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
303 if (format_ != Orthanc::PixelFormat_Grayscale16)
22628d37ef5c ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
304 {
22628d37ef5c ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
305 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
22628d37ef5c ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
306 }
22628d37ef5c ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
307
22628d37ef5c ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
308 if (x >= width_ ||
22628d37ef5c ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
309 y >= height_ ||
22628d37ef5c ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
310 z >= depth_)
22628d37ef5c ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
311 {
22628d37ef5c ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
312 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
22628d37ef5c ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
313 }
22628d37ef5c ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
314
22628d37ef5c ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
315 const void* p = image_.GetConstRow(y + height_ * (depth_ - 1 - z));
22628d37ef5c ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
316 return reinterpret_cast<const uint16_t*>(p) [x];
22628d37ef5c ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
317 }
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 }