Mercurial > hg > orthanc-stone
annotate Framework/Radiography/RadiographyMaskLayer.cpp @ 1319:0290b7060167 broker
Build fix C++03
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 17 Mar 2020 08:57:45 +0100 |
parents | 1c7ae79c426d |
children | d4e6cd35107b |
rev | line source |
---|---|
475
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
1 /** |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
2 * Stone of Orthanc |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
1280
1c7ae79c426d
fix copyright years
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1259
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
475
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
6 * |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
11 * |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
16 * |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
19 **/ |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
20 |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
21 |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
22 #include "RadiographyMaskLayer.h" |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
23 #include "RadiographyDicomLayer.h" |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
24 |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
25 #include "RadiographyScene.h" |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
26 #include "Core/Images/Image.h" |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
27 #include "Core/Images/ImageProcessing.h" |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
28 #include <Core/OrthancException.h> |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
29 #include "../Toolbox/ImageGeometry.h" |
475
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
30 |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
31 namespace OrthancStone |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
32 { |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
33 const unsigned char IN_MASK_VALUE = 0x77; |
476
a95090305dd4
Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents:
475
diff
changeset
|
34 const unsigned char OUT_MASK_VALUE = 0xFF; |
a95090305dd4
Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents:
475
diff
changeset
|
35 |
a95090305dd4
Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents:
475
diff
changeset
|
36 const AffineTransform2D& RadiographyMaskLayer::GetTransform() const |
a95090305dd4
Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents:
475
diff
changeset
|
37 { |
a95090305dd4
Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents:
475
diff
changeset
|
38 return dicomLayer_.GetTransform(); |
a95090305dd4
Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents:
475
diff
changeset
|
39 } |
a95090305dd4
Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents:
475
diff
changeset
|
40 |
a95090305dd4
Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents:
475
diff
changeset
|
41 const AffineTransform2D& RadiographyMaskLayer::GetTransformInverse() const |
a95090305dd4
Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents:
475
diff
changeset
|
42 { |
a95090305dd4
Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents:
475
diff
changeset
|
43 return dicomLayer_.GetTransformInverse(); |
a95090305dd4
Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents:
475
diff
changeset
|
44 } |
475
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
45 |
480
2f6ecb5037ea
added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
479
diff
changeset
|
46 bool RadiographyMaskLayer::GetPixel(unsigned int& imageX, |
2f6ecb5037ea
added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
479
diff
changeset
|
47 unsigned int& imageY, |
2f6ecb5037ea
added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
479
diff
changeset
|
48 double sceneX, |
2f6ecb5037ea
added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
479
diff
changeset
|
49 double sceneY) const |
2f6ecb5037ea
added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
479
diff
changeset
|
50 { |
2f6ecb5037ea
added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
479
diff
changeset
|
51 return dicomLayer_.GetPixel(imageX, imageY, sceneX, sceneY); |
2f6ecb5037ea
added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
479
diff
changeset
|
52 } |
2f6ecb5037ea
added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
479
diff
changeset
|
53 |
481
159a465e27bd
reworked RadiographyScene export to export to an Orthanc::Image too
am@osimis.io
parents:
480
diff
changeset
|
54 std::string RadiographyMaskLayer::GetInstanceId() const |
159a465e27bd
reworked RadiographyScene export to export to an Orthanc::Image too
am@osimis.io
parents:
480
diff
changeset
|
55 { |
159a465e27bd
reworked RadiographyScene export to export to an Orthanc::Image too
am@osimis.io
parents:
480
diff
changeset
|
56 return dicomLayer_.GetInstanceId(); |
159a465e27bd
reworked RadiographyScene export to export to an Orthanc::Image too
am@osimis.io
parents:
480
diff
changeset
|
57 } |
159a465e27bd
reworked RadiographyScene export to export to an Orthanc::Image too
am@osimis.io
parents:
480
diff
changeset
|
58 |
488 | 59 void RadiographyMaskLayer::SetCorner(const Orthanc::ImageProcessing::ImagePoint& corner, size_t index) |
480
2f6ecb5037ea
added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
479
diff
changeset
|
60 { |
2f6ecb5037ea
added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
479
diff
changeset
|
61 if (index < corners_.size()) |
2f6ecb5037ea
added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
479
diff
changeset
|
62 corners_[index] = corner; |
2f6ecb5037ea
added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
479
diff
changeset
|
63 else |
2f6ecb5037ea
added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
479
diff
changeset
|
64 corners_.push_back(corner); |
2f6ecb5037ea
added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
479
diff
changeset
|
65 invalidated_ = true; |
503
77e0eb83ff63
layers are now Observable and emitting LayerEdited messages
amazy
parents:
488
diff
changeset
|
66 |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
67 BroadcastMessage(RadiographyLayer::LayerEditedMessage(*this)); |
480
2f6ecb5037ea
added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
479
diff
changeset
|
68 } |
2f6ecb5037ea
added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
479
diff
changeset
|
69 |
488 | 70 void RadiographyMaskLayer::SetCorners(const std::vector<Orthanc::ImageProcessing::ImagePoint>& corners) |
475
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
71 { |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
72 corners_ = corners; |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
73 invalidated_ = true; |
503
77e0eb83ff63
layers are now Observable and emitting LayerEdited messages
amazy
parents:
488
diff
changeset
|
74 |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
503
diff
changeset
|
75 BroadcastMessage(RadiographyLayer::LayerEditedMessage(*this)); |
475
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
76 } |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
77 |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
78 void RadiographyMaskLayer::Render(Orthanc::ImageAccessor& buffer, |
479 | 79 const AffineTransform2D& viewTransform, |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
80 ImageInterpolation interpolation, |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
81 float windowCenter, |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
82 float windowWidth, |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
83 bool applyWindowing) const |
475
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
84 { |
1259
69177b10e2b9
various fixes for RadiographyScene: support text layers outside the dicom layer, fix background in this case + extract dicom from rendered scene
Alain Mazy <alain@mazy.be>
parents:
1201
diff
changeset
|
85 if (dicomLayer_.GetWidth() == 0 || dicomLayer_.GetSourceImage() == NULL) // nothing to do if the DICOM layer is not displayed (or not loaded) |
475
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
86 return; |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
87 |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
88 if (invalidated_) |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
89 { |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
90 mask_.reset(new Orthanc::Image(Orthanc::PixelFormat_Grayscale8, dicomLayer_.GetWidth(), dicomLayer_.GetHeight(), false)); |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
91 |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
92 DrawMask(); |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
93 |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
94 invalidated_ = false; |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
95 } |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
96 |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
97 {// rendering |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
98 if (buffer.GetFormat() != Orthanc::PixelFormat_Float32) |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
99 { |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
100 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
101 } |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
102 |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
103 unsigned int cropX, cropY, cropWidth, cropHeight; |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
104 dicomLayer_.GetCrop(cropX, cropY, cropWidth, cropHeight); |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
105 |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
106 const AffineTransform2D t = AffineTransform2D::Combine( |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
107 viewTransform, dicomLayer_.GetTransform(), |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
108 AffineTransform2D::CreateOffset(cropX, cropY)); |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
109 |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
110 Orthanc::ImageAccessor cropped; |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
111 mask_->GetRegion(cropped, cropX, cropY, cropWidth, cropHeight); |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
112 |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
113 Orthanc::Image tmp(Orthanc::PixelFormat_Grayscale8, buffer.GetWidth(), buffer.GetHeight(), false); |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
114 |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
115 |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
116 unsigned int x1, y1, x2, y2; |
1201 | 117 if (!OrthancStone::GetProjectiveTransformExtent(x1, y1, x2, y2, |
118 t.GetHomogeneousMatrix(), | |
119 cropped.GetWidth(), | |
120 cropped.GetHeight(), | |
121 buffer.GetWidth(), | |
122 buffer.GetHeight())) | |
123 { | |
124 return; // layer is outside the buffer | |
125 } | |
126 | |
127 t.Apply(tmp, cropped, ImageInterpolation_Nearest, true /* clear */); | |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
128 |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
129 // we have observed vertical lines at the image border (probably due to bilinear filtering of the DICOM image when it is not aligned with the buffer pixels) |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
130 // -> draw the mask one line further on each side |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
131 if (x1 >= 1) |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
132 { |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
133 x1 = x1 - 1; |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
134 } |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
135 if (x2 < buffer.GetWidth() - 2) |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
136 { |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
137 x2 = x2 + 1; |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
138 } |
475
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
139 |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
140 // Blit |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
141 for (unsigned int y = y1; y <= y2; y++) |
475
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
142 { |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
143 float *q = reinterpret_cast<float*>(buffer.GetRow(y)) + x1; |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
144 const uint8_t *p = reinterpret_cast<uint8_t*>(tmp.GetRow(y)) + x1; |
475
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
145 |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
146 for (unsigned int x = x1; x <= x2; x++, p++, q++) |
475
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
147 { |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
677
diff
changeset
|
148 if (*p != IN_MASK_VALUE) |
475
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
149 *q = foreground_; |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
150 // else keep the underlying pixel value |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
151 } |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
152 } |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
153 |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
154 } |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
155 } |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
156 |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
157 void RadiographyMaskLayer::DrawMask() const |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
158 { |
476
a95090305dd4
Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents:
475
diff
changeset
|
159 // first fill the complete image |
a95090305dd4
Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents:
475
diff
changeset
|
160 Orthanc::ImageProcessing::Set(*mask_, OUT_MASK_VALUE); |
475
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
161 |
677 | 162 // clip corners |
163 std::vector<Orthanc::ImageProcessing::ImagePoint> clippedCorners; | |
164 for (size_t i = 0; i < corners_.size(); i++) | |
165 { | |
166 clippedCorners.push_back(corners_[i]); | |
167 clippedCorners[i].ClipTo(0, mask_->GetWidth() - 1, 0, mask_->GetHeight() - 1); | |
168 } | |
169 | |
488 | 170 // fill mask |
677 | 171 Orthanc::ImageProcessing::FillPolygon(*mask_, clippedCorners, IN_MASK_VALUE); |
476
a95090305dd4
Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents:
475
diff
changeset
|
172 |
475
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
173 } |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
174 |
3c28542229a3
added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff
changeset
|
175 } |