Mercurial > hg > orthanc
annotate OrthancFramework/UnitTestsSources/ImageProcessingTests.cpp @ 4236:5639ffda467b
preparing merging InternalNode with ResourcesNode
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 09 Oct 2020 09:52:16 +0200 |
parents | bf7b9edf6b81 |
children | d9473bd5ed43 |
rev | line source |
---|---|
853 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1207
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3600
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
853 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4081
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4081
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4081
diff
changeset
|
10 * the License, or (at your option) any later version. |
853 | 11 * |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4081
diff
changeset
|
15 * Lesser General Public License for more details. |
853 | 16 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4081
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4081
diff
changeset
|
18 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4081
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
853 | 20 **/ |
21 | |
22 | |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
23 #if ORTHANC_UNIT_TESTS_LINK_FRAMEWORK == 1 |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
24 // Must be the first to be sure to use the Orthanc framework shared library |
4014
27628b0f6ada
merging logging code for plugins and files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3992
diff
changeset
|
25 # include <OrthancFramework.h> |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
26 #endif |
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
27 |
4062 | 28 #include <gtest/gtest.h> |
853 | 29 |
4045 | 30 #include "../Sources/Compatibility.h" |
31 #include "../Sources/DicomFormat/DicomImageInformation.h" | |
32 #include "../Sources/Images/Image.h" | |
33 #include "../Sources/Images/ImageProcessing.h" | |
34 #include "../Sources/Images/ImageTraits.h" | |
35 #include "../Sources/OrthancException.h" | |
2487
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
36 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
37 #include <memory> |
853 | 38 |
39 using namespace Orthanc; | |
40 | |
41 | |
855 | 42 TEST(DicomImageInformation, ExtractPixelFormat1) |
853 | 43 { |
855 | 44 // Cardiac/MR* |
45 DicomMap m; | |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
46 m.SetValue(DICOM_TAG_ROWS, "24", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
47 m.SetValue(DICOM_TAG_COLUMNS, "16", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
48 m.SetValue(DICOM_TAG_BITS_ALLOCATED, "16", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
49 m.SetValue(DICOM_TAG_SAMPLES_PER_PIXEL, "1", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
50 m.SetValue(DICOM_TAG_BITS_STORED, "12", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
51 m.SetValue(DICOM_TAG_HIGH_BIT, "11", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
52 m.SetValue(DICOM_TAG_PIXEL_REPRESENTATION, "0", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
53 m.SetValue(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2", false); |
855 | 54 |
55 DicomImageInformation info(m); | |
56 PixelFormat format; | |
1905
8b1baa2315b8
Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
57 ASSERT_TRUE(info.ExtractPixelFormat(format, false)); |
855 | 58 ASSERT_EQ(PixelFormat_Grayscale16, format); |
853 | 59 } |
855 | 60 |
61 | |
62 TEST(DicomImageInformation, ExtractPixelFormat2) | |
63 { | |
64 // Delphine CT | |
65 DicomMap m; | |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
66 m.SetValue(DICOM_TAG_ROWS, "24", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
67 m.SetValue(DICOM_TAG_COLUMNS, "16", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
68 m.SetValue(DICOM_TAG_BITS_ALLOCATED, "16", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
69 m.SetValue(DICOM_TAG_SAMPLES_PER_PIXEL, "1", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
70 m.SetValue(DICOM_TAG_BITS_STORED, "16", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
71 m.SetValue(DICOM_TAG_HIGH_BIT, "15", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
72 m.SetValue(DICOM_TAG_PIXEL_REPRESENTATION, "1", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
73 m.SetValue(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2", false); |
855 | 74 |
75 DicomImageInformation info(m); | |
76 PixelFormat format; | |
1905
8b1baa2315b8
Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
77 ASSERT_TRUE(info.ExtractPixelFormat(format, false)); |
855 | 78 ASSERT_EQ(PixelFormat_SignedGrayscale16, format); |
79 } | |
2487
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
80 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
81 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
82 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
83 namespace |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
84 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
85 template <typename T> |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
86 class TestImageTraits : public ::testing::Test |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
87 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
88 private: |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
89 std::unique_ptr<Image> image_; |
2487
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
90 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
91 protected: |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2487
diff
changeset
|
92 virtual void SetUp() ORTHANC_OVERRIDE |
2487
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
93 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
94 image_.reset(new Image(ImageTraits::PixelTraits::GetPixelFormat(), 7, 9, false)); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
95 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
96 |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2487
diff
changeset
|
97 virtual void TearDown() ORTHANC_OVERRIDE |
2487
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
98 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
99 image_.reset(NULL); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
100 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
101 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
102 public: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
103 typedef T ImageTraits; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
104 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
105 ImageAccessor& GetImage() |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
106 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
107 return *image_; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
108 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
109 }; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
110 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
111 template <typename T> |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
112 class TestIntegerImageTraits : public TestImageTraits<T> |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
113 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
114 }; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
115 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
116 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
117 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
118 typedef ::testing::Types< |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
119 ImageTraits<PixelFormat_Grayscale8>, |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
120 ImageTraits<PixelFormat_Grayscale16>, |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
121 ImageTraits<PixelFormat_SignedGrayscale16> |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
122 > IntegerFormats; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
123 TYPED_TEST_CASE(TestIntegerImageTraits, IntegerFormats); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
124 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
125 typedef ::testing::Types< |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
126 ImageTraits<PixelFormat_Grayscale8>, |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
127 ImageTraits<PixelFormat_Grayscale16>, |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
128 ImageTraits<PixelFormat_SignedGrayscale16>, |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
129 ImageTraits<PixelFormat_RGB24>, |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
130 ImageTraits<PixelFormat_BGRA32> |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
131 > AllFormats; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
132 TYPED_TEST_CASE(TestImageTraits, AllFormats); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
133 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
134 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
135 TYPED_TEST(TestImageTraits, SetZero) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
136 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
137 ImageAccessor& image = this->GetImage(); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
138 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
139 memset(image.GetBuffer(), 128, image.GetHeight() * image.GetWidth()); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
140 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
141 switch (image.GetFormat()) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
142 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
143 case PixelFormat_Grayscale8: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
144 case PixelFormat_Grayscale16: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
145 case PixelFormat_SignedGrayscale16: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
146 ImageProcessing::Set(image, 0); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
147 break; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
148 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
149 case PixelFormat_RGB24: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
150 case PixelFormat_BGRA32: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
151 ImageProcessing::Set(image, 0, 0, 0, 0); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
152 break; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
153 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
154 default: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
155 ASSERT_TRUE(0); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
156 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
157 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
158 typename TestFixture::ImageTraits::PixelType zero, value; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
159 TestFixture::ImageTraits::PixelTraits::SetZero(zero); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
160 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
161 for (unsigned int y = 0; y < image.GetHeight(); y++) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
162 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
163 for (unsigned int x = 0; x < image.GetWidth(); x++) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
164 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
165 TestFixture::ImageTraits::GetPixel(value, image, x, y); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
166 ASSERT_TRUE(TestFixture::ImageTraits::PixelTraits::IsEqual(zero, value)); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
167 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
168 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
169 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
170 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
171 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
172 TYPED_TEST(TestIntegerImageTraits, SetZeroFloat) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
173 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
174 ImageAccessor& image = this->GetImage(); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
175 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
176 memset(image.GetBuffer(), 128, image.GetHeight() * image.GetWidth()); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
177 |
3258 | 178 float c = 0.0f; |
2487
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
179 for (unsigned int y = 0; y < image.GetHeight(); y++) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
180 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
181 for (unsigned int x = 0; x < image.GetWidth(); x++, c++) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
182 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
183 TestFixture::ImageTraits::SetFloatPixel(image, c, x, y); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
184 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
185 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
186 |
3260
345f86fd1ac3
fix (shame on me for not testing)
Alain Mazy <alain@mazy.be>
parents:
3258
diff
changeset
|
187 c = 0.0f; |
2487
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
188 for (unsigned int y = 0; y < image.GetHeight(); y++) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
189 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
190 for (unsigned int x = 0; x < image.GetWidth(); x++, c++) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
191 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
192 ASSERT_FLOAT_EQ(c, TestFixture::ImageTraits::GetFloatPixel(image, x, y)); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
193 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
194 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
195 } |
3258 | 196 |
197 TYPED_TEST(TestIntegerImageTraits, FillPolygon) | |
198 { | |
199 ImageAccessor& image = this->GetImage(); | |
200 | |
201 ImageProcessing::Set(image, 128); | |
202 | |
203 // draw a triangle | |
204 std::vector<ImageProcessing::ImagePoint> points; | |
205 points.push_back(ImageProcessing::ImagePoint(1,1)); | |
206 points.push_back(ImageProcessing::ImagePoint(1,5)); | |
207 points.push_back(ImageProcessing::ImagePoint(5,5)); | |
208 | |
3503
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
209 ImageProcessing::FillPolygon(image, points, 255); |
3258 | 210 |
211 // outside polygon | |
212 ASSERT_FLOAT_EQ(128, TestFixture::ImageTraits::GetFloatPixel(image, 0, 0)); | |
213 ASSERT_FLOAT_EQ(128, TestFixture::ImageTraits::GetFloatPixel(image, 0, 6)); | |
214 ASSERT_FLOAT_EQ(128, TestFixture::ImageTraits::GetFloatPixel(image, 6, 6)); | |
215 ASSERT_FLOAT_EQ(128, TestFixture::ImageTraits::GetFloatPixel(image, 6, 0)); | |
216 | |
3431 | 217 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 1, 1)); |
3258 | 218 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 1, 2)); |
3431 | 219 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 1, 5)); |
3258 | 220 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 2, 4)); |
3431 | 221 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 5, 5)); |
3258 | 222 } |
3365 | 223 |
3366 | 224 TYPED_TEST(TestIntegerImageTraits, FillPolygonLargerThanImage) |
3365 | 225 { |
226 ImageAccessor& image = this->GetImage(); | |
227 | |
228 ImageProcessing::Set(image, 0); | |
229 | |
230 std::vector<ImageProcessing::ImagePoint> points; | |
231 points.push_back(ImageProcessing::ImagePoint(0, 0)); | |
232 points.push_back(ImageProcessing::ImagePoint(image.GetWidth(),0)); | |
233 points.push_back(ImageProcessing::ImagePoint(image.GetWidth(),image.GetHeight())); | |
234 points.push_back(ImageProcessing::ImagePoint(0,image.GetHeight())); | |
235 | |
3503
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
236 ASSERT_THROW(ImageProcessing::FillPolygon(image, points, 255), OrthancException); |
3365 | 237 } |
238 | |
239 TYPED_TEST(TestIntegerImageTraits, FillPolygonFullImage) | |
240 { | |
241 ImageAccessor& image = this->GetImage(); | |
242 | |
243 ImageProcessing::Set(image, 0); | |
244 | |
245 std::vector<ImageProcessing::ImagePoint> points; | |
246 points.push_back(ImageProcessing::ImagePoint(0, 0)); | |
247 points.push_back(ImageProcessing::ImagePoint(image.GetWidth() - 1,0)); | |
248 points.push_back(ImageProcessing::ImagePoint(image.GetWidth() - 1,image.GetHeight() - 1)); | |
249 points.push_back(ImageProcessing::ImagePoint(0,image.GetHeight() - 1)); | |
250 | |
3503
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
251 ImageProcessing::FillPolygon(image, points, 255); |
3365 | 252 |
3431 | 253 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 0, 0)); |
254 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, image.GetWidth() - 1, image.GetHeight() - 1)); | |
3365 | 255 } |
3503
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
256 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
257 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
258 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
259 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
260 static void SetGrayscale8Pixel(ImageAccessor& image, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
261 unsigned int x, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
262 unsigned int y, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
263 uint8_t value) |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
264 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
265 ImageTraits<PixelFormat_Grayscale8>::SetPixel(image, value, x, y); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
266 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
267 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
268 static bool TestGrayscale8Pixel(const ImageAccessor& image, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
269 unsigned int x, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
270 unsigned int y, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
271 uint8_t value) |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
272 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
273 PixelTraits<PixelFormat_Grayscale8>::PixelType p; |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
274 ImageTraits<PixelFormat_Grayscale8>::GetPixel(p, image, x, y); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
275 if (p != value) printf("%d %d\n", p, value); |
3503
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
276 return p == value; |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
277 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
278 |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
279 static void SetGrayscale16Pixel(ImageAccessor& image, |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
280 unsigned int x, |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
281 unsigned int y, |
3682
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
282 uint16_t value) |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
283 { |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
284 ImageTraits<PixelFormat_Grayscale16>::SetPixel(image, value, x, y); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
285 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
286 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
287 static bool TestGrayscale16Pixel(const ImageAccessor& image, |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
288 unsigned int x, |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
289 unsigned int y, |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
290 uint16_t value) |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
291 { |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
292 PixelTraits<PixelFormat_Grayscale16>::PixelType p; |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
293 ImageTraits<PixelFormat_Grayscale16>::GetPixel(p, image, x, y); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
294 if (p != value) printf("%d %d\n", p, value); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
295 return p == value; |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
296 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
297 |
3682
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
298 static void SetSignedGrayscale16Pixel(ImageAccessor& image, |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
299 unsigned int x, |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
300 unsigned int y, |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
301 int16_t value) |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
302 { |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
303 ImageTraits<PixelFormat_SignedGrayscale16>::SetPixel(image, value, x, y); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
304 } |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
305 |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
306 static bool TestSignedGrayscale16Pixel(const ImageAccessor& image, |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
307 unsigned int x, |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
308 unsigned int y, |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
309 int16_t value) |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
310 { |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
311 PixelTraits<PixelFormat_SignedGrayscale16>::PixelType p; |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
312 ImageTraits<PixelFormat_SignedGrayscale16>::GetPixel(p, image, x, y); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
313 if (p != value) printf("%d %d\n", p, value); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
314 return p == value; |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
315 } |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
316 |
3503
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
317 static void SetRGB24Pixel(ImageAccessor& image, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
318 unsigned int x, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
319 unsigned int y, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
320 uint8_t red, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
321 uint8_t green, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
322 uint8_t blue) |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
323 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
324 PixelTraits<PixelFormat_RGB24>::PixelType p; |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
325 p.red_ = red; |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
326 p.green_ = green; |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
327 p.blue_ = blue; |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
328 ImageTraits<PixelFormat_RGB24>::SetPixel(image, p, x, y); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
329 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
330 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
331 static bool TestRGB24Pixel(const ImageAccessor& image, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
332 unsigned int x, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
333 unsigned int y, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
334 uint8_t red, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
335 uint8_t green, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
336 uint8_t blue) |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
337 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
338 PixelTraits<PixelFormat_RGB24>::PixelType p; |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
339 ImageTraits<PixelFormat_RGB24>::GetPixel(p, image, x, y); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
340 bool ok = (p.red_ == red && |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
341 p.green_ == green && |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
342 p.blue_ == blue); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
343 if (!ok) printf("%d,%d,%d %d,%d,%d\n", p.red_, p.green_, p.blue_, red, green, blue); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
344 return ok; |
3503
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
345 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
346 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
347 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
348 TEST(ImageProcessing, FlipGrayscale8) |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
349 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
350 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
351 Image image(PixelFormat_Grayscale8, 0, 0, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
352 ImageProcessing::FlipX(image); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
353 ImageProcessing::FlipY(image); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
354 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
355 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
356 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
357 Image image(PixelFormat_Grayscale8, 1, 1, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
358 SetGrayscale8Pixel(image, 0, 0, 128); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
359 ImageProcessing::FlipX(image); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
360 ImageProcessing::FlipY(image); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
361 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 0, 128)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
362 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
363 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
364 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
365 Image image(PixelFormat_Grayscale8, 3, 2, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
366 SetGrayscale8Pixel(image, 0, 0, 10); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
367 SetGrayscale8Pixel(image, 1, 0, 20); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
368 SetGrayscale8Pixel(image, 2, 0, 30); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
369 SetGrayscale8Pixel(image, 0, 1, 40); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
370 SetGrayscale8Pixel(image, 1, 1, 50); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
371 SetGrayscale8Pixel(image, 2, 1, 60); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
372 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
373 ImageProcessing::FlipX(image); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
374 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 0, 30)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
375 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 0, 20)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
376 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 0, 10)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
377 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 1, 60)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
378 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 1, 50)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
379 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 1, 40)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
380 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
381 ImageProcessing::FlipY(image); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
382 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 0, 60)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
383 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 0, 50)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
384 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 0, 40)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
385 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 1, 30)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
386 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 1, 20)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
387 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 1, 10)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
388 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
389 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
390 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
391 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
392 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
393 TEST(ImageProcessing, FlipRGB24) |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
394 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
395 Image image(PixelFormat_RGB24, 2, 2, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
396 SetRGB24Pixel(image, 0, 0, 10, 100, 110); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
397 SetRGB24Pixel(image, 1, 0, 20, 100, 110); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
398 SetRGB24Pixel(image, 0, 1, 30, 100, 110); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
399 SetRGB24Pixel(image, 1, 1, 40, 100, 110); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
400 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
401 ImageProcessing::FlipX(image); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
402 ASSERT_TRUE(TestRGB24Pixel(image, 0, 0, 20, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
403 ASSERT_TRUE(TestRGB24Pixel(image, 1, 0, 10, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
404 ASSERT_TRUE(TestRGB24Pixel(image, 0, 1, 40, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
405 ASSERT_TRUE(TestRGB24Pixel(image, 1, 1, 30, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
406 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
407 ImageProcessing::FlipY(image); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
408 ASSERT_TRUE(TestRGB24Pixel(image, 0, 0, 40, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
409 ASSERT_TRUE(TestRGB24Pixel(image, 1, 0, 30, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
410 ASSERT_TRUE(TestRGB24Pixel(image, 0, 1, 20, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
411 ASSERT_TRUE(TestRGB24Pixel(image, 1, 1, 10, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
412 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
413 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
414 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
415 TEST(ImageProcessing, ResizeBasicGrayscale8) |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
416 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
417 Image source(PixelFormat_Grayscale8, 2, 2, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
418 SetGrayscale8Pixel(source, 0, 0, 10); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
419 SetGrayscale8Pixel(source, 1, 0, 20); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
420 SetGrayscale8Pixel(source, 0, 1, 30); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
421 SetGrayscale8Pixel(source, 1, 1, 40); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
422 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
423 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
424 Image target(PixelFormat_Grayscale8, 2, 4, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
425 ImageProcessing::Resize(target, source); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
426 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 0, 10)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
427 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 0, 20)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
428 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 1, 10)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
429 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 1, 20)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
430 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 2, 30)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
431 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 2, 40)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
432 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 3, 30)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
433 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 3, 40)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
434 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
435 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
436 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
437 Image target(PixelFormat_Grayscale8, 4, 2, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
438 ImageProcessing::Resize(target, source); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
439 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 0, 10)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
440 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 0, 10)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
441 ASSERT_TRUE(TestGrayscale8Pixel(target, 2, 0, 20)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
442 ASSERT_TRUE(TestGrayscale8Pixel(target, 3, 0, 20)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
443 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 1, 30)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
444 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 1, 30)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
445 ASSERT_TRUE(TestGrayscale8Pixel(target, 2, 1, 40)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
446 ASSERT_TRUE(TestGrayscale8Pixel(target, 3, 1, 40)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
447 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
448 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
449 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
450 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
451 TEST(ImageProcessing, ResizeBasicRGB24) |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
452 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
453 Image source(PixelFormat_RGB24, 2, 2, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
454 SetRGB24Pixel(source, 0, 0, 10, 100, 110); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
455 SetRGB24Pixel(source, 1, 0, 20, 100, 110); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
456 SetRGB24Pixel(source, 0, 1, 30, 100, 110); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
457 SetRGB24Pixel(source, 1, 1, 40, 100, 110); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
458 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
459 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
460 Image target(PixelFormat_RGB24, 2, 4, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
461 ImageProcessing::Resize(target, source); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
462 ASSERT_TRUE(TestRGB24Pixel(target, 0, 0, 10, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
463 ASSERT_TRUE(TestRGB24Pixel(target, 1, 0, 20, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
464 ASSERT_TRUE(TestRGB24Pixel(target, 0, 1, 10, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
465 ASSERT_TRUE(TestRGB24Pixel(target, 1, 1, 20, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
466 ASSERT_TRUE(TestRGB24Pixel(target, 0, 2, 30, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
467 ASSERT_TRUE(TestRGB24Pixel(target, 1, 2, 40, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
468 ASSERT_TRUE(TestRGB24Pixel(target, 0, 3, 30, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
469 ASSERT_TRUE(TestRGB24Pixel(target, 1, 3, 40, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
470 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
471 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
472 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
473 Image target(PixelFormat_RGB24, 4, 2, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
474 ImageProcessing::Resize(target, source); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
475 ASSERT_TRUE(TestRGB24Pixel(target, 0, 0, 10, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
476 ASSERT_TRUE(TestRGB24Pixel(target, 1, 0, 10, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
477 ASSERT_TRUE(TestRGB24Pixel(target, 2, 0, 20, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
478 ASSERT_TRUE(TestRGB24Pixel(target, 3, 0, 20, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
479 ASSERT_TRUE(TestRGB24Pixel(target, 0, 1, 30, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
480 ASSERT_TRUE(TestRGB24Pixel(target, 1, 1, 30, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
481 ASSERT_TRUE(TestRGB24Pixel(target, 2, 1, 40, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
482 ASSERT_TRUE(TestRGB24Pixel(target, 3, 1, 40, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
483 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
484 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
485 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
486 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
487 TEST(ImageProcessing, ResizeEmptyGrayscale8) |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
488 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
489 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
490 Image source(PixelFormat_Grayscale8, 0, 0, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
491 Image target(PixelFormat_Grayscale8, 2, 2, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
492 ImageProcessing::Resize(target, source); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
493 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 0, 0)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
494 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 0, 0)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
495 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 1, 0)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
496 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 1, 0)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
497 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
498 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
499 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
500 Image source(PixelFormat_Grayscale8, 2, 2, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
501 Image target(PixelFormat_Grayscale8, 0, 0, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
502 ImageProcessing::Resize(target, source); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
503 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
504 } |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
505 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
506 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
507 TEST(ImageProcessing, Convolution) |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
508 { |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
509 std::vector<float> k1(5, 1); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
510 std::vector<float> k2(1, 1); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
511 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
512 { |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
513 Image image(PixelFormat_Grayscale8, 1, 1, false); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
514 SetGrayscale8Pixel(image, 0, 0, 100); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
515 ImageProcessing::SeparableConvolution(image, k1, 2, k2, 0, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
516 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 0, 100)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
517 ImageProcessing::SeparableConvolution(image, k1, 2, k1, 2, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
518 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 0, 100)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
519 ImageProcessing::SeparableConvolution(image, k2, 0, k1, 2, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
520 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 0, 100)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
521 ImageProcessing::SeparableConvolution(image, k2, 0, k2, 0, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
522 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 0, 100)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
523 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
524 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
525 { |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
526 Image image(PixelFormat_RGB24, 1, 1, false); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
527 SetRGB24Pixel(image, 0, 0, 10, 20, 30); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
528 ImageProcessing::SeparableConvolution(image, k1, 2, k2, 0, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
529 ASSERT_TRUE(TestRGB24Pixel(image, 0, 0, 10, 20, 30)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
530 ImageProcessing::SeparableConvolution(image, k1, 2, k1, 2, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
531 ASSERT_TRUE(TestRGB24Pixel(image, 0, 0, 10, 20, 30)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
532 ImageProcessing::SeparableConvolution(image, k2, 0, k1, 2, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
533 ASSERT_TRUE(TestRGB24Pixel(image, 0, 0, 10, 20, 30)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
534 ImageProcessing::SeparableConvolution(image, k2, 0, k2, 0, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
535 ASSERT_TRUE(TestRGB24Pixel(image, 0, 0, 10, 20, 30)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
536 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
537 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
538 { |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
539 Image dirac(PixelFormat_Grayscale8, 9, 1, false); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
540 ImageProcessing::Set(dirac, 0); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
541 SetGrayscale8Pixel(dirac, 4, 0, 100); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
542 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
543 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
544 std::unique_ptr<ImageAccessor> image(Image::Clone(dirac)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
545 ImageProcessing::SeparableConvolution(*image, k1, 2, k2, 0, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
546 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
547 ASSERT_TRUE(TestGrayscale8Pixel(*image, 1, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
548 ASSERT_TRUE(TestGrayscale8Pixel(*image, 2, 0, 20)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
549 ASSERT_TRUE(TestGrayscale8Pixel(*image, 3, 0, 20)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
550 ASSERT_TRUE(TestGrayscale8Pixel(*image, 4, 0, 20)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
551 ASSERT_TRUE(TestGrayscale8Pixel(*image, 5, 0, 20)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
552 ASSERT_TRUE(TestGrayscale8Pixel(*image, 6, 0, 20)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
553 ASSERT_TRUE(TestGrayscale8Pixel(*image, 7, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
554 ASSERT_TRUE(TestGrayscale8Pixel(*image, 8, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
555 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
556 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
557 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
558 std::unique_ptr<ImageAccessor> image(Image::Clone(dirac)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
559 ImageProcessing::SeparableConvolution(*image, k2, 0, k1, 2, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
560 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
561 ASSERT_TRUE(TestGrayscale8Pixel(*image, 1, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
562 ASSERT_TRUE(TestGrayscale8Pixel(*image, 2, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
563 ASSERT_TRUE(TestGrayscale8Pixel(*image, 3, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
564 ASSERT_TRUE(TestGrayscale8Pixel(*image, 4, 0, 100)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
565 ASSERT_TRUE(TestGrayscale8Pixel(*image, 5, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
566 ASSERT_TRUE(TestGrayscale8Pixel(*image, 6, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
567 ASSERT_TRUE(TestGrayscale8Pixel(*image, 7, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
568 ASSERT_TRUE(TestGrayscale8Pixel(*image, 8, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
569 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
570 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
571 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
572 std::unique_ptr<ImageAccessor> image(Image::Clone(dirac)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
573 ImageProcessing::SeparableConvolution(*image, k2, 0, k2, 0, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
574 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
575 ASSERT_TRUE(TestGrayscale8Pixel(*image, 1, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
576 ASSERT_TRUE(TestGrayscale8Pixel(*image, 2, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
577 ASSERT_TRUE(TestGrayscale8Pixel(*image, 3, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
578 ASSERT_TRUE(TestGrayscale8Pixel(*image, 4, 0, 100)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
579 ASSERT_TRUE(TestGrayscale8Pixel(*image, 5, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
580 ASSERT_TRUE(TestGrayscale8Pixel(*image, 6, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
581 ASSERT_TRUE(TestGrayscale8Pixel(*image, 7, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
582 ASSERT_TRUE(TestGrayscale8Pixel(*image, 8, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
583 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
584 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
585 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
586 { |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
587 Image dirac(PixelFormat_Grayscale8, 1, 9, false); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
588 ImageProcessing::Set(dirac, 0); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
589 SetGrayscale8Pixel(dirac, 0, 4, 100); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
590 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
591 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
592 std::unique_ptr<ImageAccessor> image(Image::Clone(dirac)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
593 ImageProcessing::SeparableConvolution(*image, k2, 0, k1, 2, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
594 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
595 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 1, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
596 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 2, 20)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
597 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 3, 20)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
598 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 4, 20)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
599 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 5, 20)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
600 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 6, 20)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
601 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 7, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
602 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 8, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
603 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
604 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
605 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
606 std::unique_ptr<ImageAccessor> image(Image::Clone(dirac)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
607 ImageProcessing::SeparableConvolution(*image, k1, 2, k2, 0, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
608 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
609 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 1, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
610 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 2, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
611 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 3, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
612 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 4, 100)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
613 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 5, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
614 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 6, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
615 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 7, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
616 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 8, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
617 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
618 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
619 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
620 std::unique_ptr<ImageAccessor> image(Image::Clone(dirac)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
621 ImageProcessing::SeparableConvolution(*image, k2, 0, k2, 0, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
622 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
623 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 1, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
624 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 2, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
625 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 3, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
626 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 4, 100)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
627 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 5, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
628 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 6, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
629 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 7, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
630 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 8, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
631 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
632 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
633 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
634 { |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
635 Image dirac(PixelFormat_RGB24, 9, 1, false); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
636 ImageProcessing::Set(dirac, 0); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
637 SetRGB24Pixel(dirac, 4, 0, 100, 120, 140); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
638 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
639 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
640 std::unique_ptr<ImageAccessor> image(Image::Clone(dirac)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
641 ImageProcessing::SeparableConvolution(*image, k1, 2, k2, 0, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
642 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
643 ASSERT_TRUE(TestRGB24Pixel(*image, 1, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
644 ASSERT_TRUE(TestRGB24Pixel(*image, 2, 0, 20, 24, 28)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
645 ASSERT_TRUE(TestRGB24Pixel(*image, 3, 0, 20, 24, 28)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
646 ASSERT_TRUE(TestRGB24Pixel(*image, 4, 0, 20, 24, 28)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
647 ASSERT_TRUE(TestRGB24Pixel(*image, 5, 0, 20, 24, 28)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
648 ASSERT_TRUE(TestRGB24Pixel(*image, 6, 0, 20, 24, 28)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
649 ASSERT_TRUE(TestRGB24Pixel(*image, 7, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
650 ASSERT_TRUE(TestRGB24Pixel(*image, 8, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
651 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
652 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
653 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
654 std::unique_ptr<ImageAccessor> image(Image::Clone(dirac)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
655 ImageProcessing::SeparableConvolution(*image, k2, 0, k1, 2, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
656 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
657 ASSERT_TRUE(TestRGB24Pixel(*image, 1, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
658 ASSERT_TRUE(TestRGB24Pixel(*image, 2, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
659 ASSERT_TRUE(TestRGB24Pixel(*image, 3, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
660 ASSERT_TRUE(TestRGB24Pixel(*image, 4, 0, 100, 120, 140)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
661 ASSERT_TRUE(TestRGB24Pixel(*image, 5, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
662 ASSERT_TRUE(TestRGB24Pixel(*image, 6, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
663 ASSERT_TRUE(TestRGB24Pixel(*image, 7, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
664 ASSERT_TRUE(TestRGB24Pixel(*image, 8, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
665 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
666 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
667 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
668 std::unique_ptr<ImageAccessor> image(Image::Clone(dirac)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
669 ImageProcessing::SeparableConvolution(*image, k2, 0, k2, 0, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
670 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
671 ASSERT_TRUE(TestRGB24Pixel(*image, 1, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
672 ASSERT_TRUE(TestRGB24Pixel(*image, 2, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
673 ASSERT_TRUE(TestRGB24Pixel(*image, 3, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
674 ASSERT_TRUE(TestRGB24Pixel(*image, 4, 0, 100, 120, 140)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
675 ASSERT_TRUE(TestRGB24Pixel(*image, 5, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
676 ASSERT_TRUE(TestRGB24Pixel(*image, 6, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
677 ASSERT_TRUE(TestRGB24Pixel(*image, 7, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
678 ASSERT_TRUE(TestRGB24Pixel(*image, 8, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
679 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
680 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
681 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
682 { |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
683 Image dirac(PixelFormat_RGB24, 1, 9, false); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
684 ImageProcessing::Set(dirac, 0); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
685 SetRGB24Pixel(dirac, 0, 4, 100, 120, 140); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
686 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
687 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
688 std::unique_ptr<ImageAccessor> image(Image::Clone(dirac)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
689 ImageProcessing::SeparableConvolution(*image, k2, 0, k1, 2, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
690 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
691 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 1, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
692 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 2, 20, 24, 28)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
693 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 3, 20, 24, 28)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
694 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 4, 20, 24, 28)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
695 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 5, 20, 24, 28)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
696 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 6, 20, 24, 28)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
697 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 7, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
698 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 8, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
699 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
700 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
701 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
702 std::unique_ptr<ImageAccessor> image(Image::Clone(dirac)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
703 ImageProcessing::SeparableConvolution(*image, k1, 2, k2, 0, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
704 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
705 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 1, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
706 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 2, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
707 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 3, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
708 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 4, 100, 120, 140)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
709 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 5, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
710 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 6, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
711 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 7, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
712 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 8, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
713 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
714 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
715 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
716 std::unique_ptr<ImageAccessor> image(Image::Clone(dirac)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
717 ImageProcessing::SeparableConvolution(*image, k2, 0, k2, 0, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
718 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 0, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
719 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 1, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
720 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 2, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
721 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 3, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
722 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 4, 100, 120, 140)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
723 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 5, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
724 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 6, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
725 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 7, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
726 ASSERT_TRUE(TestRGB24Pixel(*image, 0, 8, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
727 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
728 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
729 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
730 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
731 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
732 TEST(ImageProcessing, SmoothGaussian5x5) |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
733 { |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
734 /** |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
735 Test the point spread function, as can be seen in Octave: |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
736 g1 = [ 1 4 6 4 1 ]; |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
737 g1 /= sum(g1); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
738 g2 = conv2(g1, g1'); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
739 floor(conv2(diag([ 0 0 100 0 0 ]), g2, 'same')) % red/green channels |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
740 floor(conv2(diag([ 0 0 200 0 0 ]), g2, 'same')) % blue channel |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
741 **/ |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
742 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
743 { |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
744 Image image(PixelFormat_Grayscale8, 5, 5, false); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
745 ImageProcessing::Set(image, 0); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
746 SetGrayscale8Pixel(image, 2, 2, 100); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
747 ImageProcessing::SmoothGaussian5x5(image, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
748 |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
749 // In Octave: round(conv2([1 4 6 4 1],[1 4 6 4 1]')/256*100) |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
750 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 0, 0)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
751 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 0, 2)); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
752 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 0, 2)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
753 ASSERT_TRUE(TestGrayscale8Pixel(image, 3, 0, 2)); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
754 ASSERT_TRUE(TestGrayscale8Pixel(image, 4, 0, 0)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
755 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 1, 2)); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
756 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 1, 6)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
757 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 1, 9)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
758 ASSERT_TRUE(TestGrayscale8Pixel(image, 3, 1, 6)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
759 ASSERT_TRUE(TestGrayscale8Pixel(image, 4, 1, 2)); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
760 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 2, 2)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
761 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 2, 9)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
762 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 2, 14)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
763 ASSERT_TRUE(TestGrayscale8Pixel(image, 3, 2, 9)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
764 ASSERT_TRUE(TestGrayscale8Pixel(image, 4, 2, 2)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
765 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 3, 2)); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
766 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 3, 6)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
767 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 3, 9)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
768 ASSERT_TRUE(TestGrayscale8Pixel(image, 3, 3, 6)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
769 ASSERT_TRUE(TestGrayscale8Pixel(image, 4, 3, 2)); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
770 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 4, 0)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
771 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 4, 2)); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
772 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 4, 2)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
773 ASSERT_TRUE(TestGrayscale8Pixel(image, 3, 4, 2)); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
774 ASSERT_TRUE(TestGrayscale8Pixel(image, 4, 4, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
775 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
776 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
777 { |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
778 Image image(PixelFormat_RGB24, 5, 5, false); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
779 ImageProcessing::Set(image, 0); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
780 SetRGB24Pixel(image, 2, 2, 100, 100, 200); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
781 ImageProcessing::SmoothGaussian5x5(image, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
782 |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
783 // In Octave: |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
784 // R,G = round(conv2([1 4 6 4 1],[1 4 6 4 1]')/256*100) |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
785 // B = round(conv2([1 4 6 4 1],[1 4 6 4 1]')/256*200) |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
786 ASSERT_TRUE(TestRGB24Pixel(image, 0, 0, 0, 0, 1)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
787 ASSERT_TRUE(TestRGB24Pixel(image, 1, 0, 2, 2, 3)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
788 ASSERT_TRUE(TestRGB24Pixel(image, 2, 0, 2, 2, 5)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
789 ASSERT_TRUE(TestRGB24Pixel(image, 3, 0, 2, 2, 3)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
790 ASSERT_TRUE(TestRGB24Pixel(image, 4, 0, 0, 0, 1)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
791 ASSERT_TRUE(TestRGB24Pixel(image, 0, 1, 2, 2, 3)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
792 ASSERT_TRUE(TestRGB24Pixel(image, 1, 1, 6, 6, 13)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
793 ASSERT_TRUE(TestRGB24Pixel(image, 2, 1, 9, 9, 19)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
794 ASSERT_TRUE(TestRGB24Pixel(image, 3, 1, 6, 6, 13)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
795 ASSERT_TRUE(TestRGB24Pixel(image, 4, 1, 2, 2, 3)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
796 ASSERT_TRUE(TestRGB24Pixel(image, 0, 2, 2, 2, 5)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
797 ASSERT_TRUE(TestRGB24Pixel(image, 1, 2, 9, 9, 19)); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
798 ASSERT_TRUE(TestRGB24Pixel(image, 2, 2, 14, 14, 28)); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
799 ASSERT_TRUE(TestRGB24Pixel(image, 3, 2, 9, 9, 19)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
800 ASSERT_TRUE(TestRGB24Pixel(image, 4, 2, 2, 2, 5)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
801 ASSERT_TRUE(TestRGB24Pixel(image, 0, 3, 2, 2, 3)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
802 ASSERT_TRUE(TestRGB24Pixel(image, 1, 3, 6, 6, 13)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
803 ASSERT_TRUE(TestRGB24Pixel(image, 2, 3, 9, 9, 19)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
804 ASSERT_TRUE(TestRGB24Pixel(image, 3, 3, 6, 6, 13)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
805 ASSERT_TRUE(TestRGB24Pixel(image, 4, 3, 2, 2, 3)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
806 ASSERT_TRUE(TestRGB24Pixel(image, 0, 4, 0, 0, 1)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
807 ASSERT_TRUE(TestRGB24Pixel(image, 1, 4, 2, 2, 3)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
808 ASSERT_TRUE(TestRGB24Pixel(image, 2, 4, 2, 2, 5)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
809 ASSERT_TRUE(TestRGB24Pixel(image, 3, 4, 2, 2, 3)); |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
810 ASSERT_TRUE(TestRGB24Pixel(image, 4, 4, 0, 0, 1)); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
811 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
812 } |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
813 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
814 TEST(ImageProcessing, ApplyWindowingFloatToGrayScale8) |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
815 { |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
816 { |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
817 Image image(PixelFormat_Float32, 6, 1, false); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
818 ImageTraits<PixelFormat_Float32>::SetFloatPixel(image, -5.0f, 0, 0); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
819 ImageTraits<PixelFormat_Float32>::SetFloatPixel(image, 0.0f, 1, 0); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
820 ImageTraits<PixelFormat_Float32>::SetFloatPixel(image, 5.0f, 2, 0); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
821 ImageTraits<PixelFormat_Float32>::SetFloatPixel(image, 10.0f, 3, 0); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
822 ImageTraits<PixelFormat_Float32>::SetFloatPixel(image, 1000.0f, 4, 0); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
823 ImageTraits<PixelFormat_Float32>::SetFloatPixel(image, 2.0f, 5, 0); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
824 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
825 { |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
826 Image target(PixelFormat_Grayscale8, 6, 1, false); |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3682
diff
changeset
|
827 ImageProcessing::ApplyWindowing_Deprecated(target, image, 5.0f, 10.0f, 1.0f, 0.0f, false); |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
828 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
829 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 0, 0)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
830 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 0, 0)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
831 ASSERT_TRUE(TestGrayscale8Pixel(target, 2, 0, 128)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
832 ASSERT_TRUE(TestGrayscale8Pixel(target, 3, 0, 255)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
833 ASSERT_TRUE(TestGrayscale8Pixel(target, 4, 0, 255)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
834 ASSERT_TRUE(TestGrayscale8Pixel(target, 5, 0, 255*2/10)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
835 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
836 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
837 { |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
838 Image target(PixelFormat_Grayscale8, 6, 1, false); |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3682
diff
changeset
|
839 ImageProcessing::ApplyWindowing_Deprecated(target, image, 5.0f, 10.0f, 1.0f, 0.0f, true); |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
840 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
841 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 0, 255)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
842 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 0, 255)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
843 ASSERT_TRUE(TestGrayscale8Pixel(target, 2, 0, 127)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
844 ASSERT_TRUE(TestGrayscale8Pixel(target, 3, 0, 0)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
845 ASSERT_TRUE(TestGrayscale8Pixel(target, 4, 0, 0)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
846 ASSERT_TRUE(TestGrayscale8Pixel(target, 5, 0, 255 - 255*2/10)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
847 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
848 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
849 { |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
850 Image target(PixelFormat_Grayscale8, 6, 1, false); |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3682
diff
changeset
|
851 ImageProcessing::ApplyWindowing_Deprecated(target, image, 5000.0f, 10000.01f, 1000.0f, 0.0f, false); |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
852 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
853 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 0, 0)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
854 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 0, 0)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
855 ASSERT_TRUE(TestGrayscale8Pixel(target, 2, 0, 128)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
856 ASSERT_TRUE(TestGrayscale8Pixel(target, 3, 0, 255)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
857 ASSERT_TRUE(TestGrayscale8Pixel(target, 4, 0, 255)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
858 ASSERT_TRUE(TestGrayscale8Pixel(target, 5, 0, 255*2/10)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
859 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
860 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
861 { |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
862 Image target(PixelFormat_Grayscale8, 6, 1, false); |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3682
diff
changeset
|
863 ImageProcessing::ApplyWindowing_Deprecated(target, image, 5000.0f, 10000.01f, 1000.0f, 0.0f, true); |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
864 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
865 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 0, 255)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
866 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 0, 255)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
867 ASSERT_TRUE(TestGrayscale8Pixel(target, 2, 0, 127)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
868 ASSERT_TRUE(TestGrayscale8Pixel(target, 3, 0, 0)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
869 ASSERT_TRUE(TestGrayscale8Pixel(target, 4, 0, 0)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
870 ASSERT_TRUE(TestGrayscale8Pixel(target, 5, 0, 255 - 256*2/10)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
871 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
872 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
873 { |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
874 Image target(PixelFormat_Grayscale8, 6, 1, false); |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3682
diff
changeset
|
875 ImageProcessing::ApplyWindowing_Deprecated(target, image, 50.0f, 100.1f, 10.0f, 30.0f, false); |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
876 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
877 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 0, 0)); // (-5 * 10) + 30 => pixel value = -20 => 0 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
878 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 0, 256*30/100)); // ((0 * 10) + 30 => pixel value = 30 => 30% |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
879 ASSERT_TRUE(TestGrayscale8Pixel(target, 2, 0, 256*80/100)); // ((5 * 10) + 30 => pixel value = 80 => 80% |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
880 ASSERT_TRUE(TestGrayscale8Pixel(target, 3, 0, 255)); // ((10 * 10) + 30 => pixel value = 130 => 100% |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
881 ASSERT_TRUE(TestGrayscale8Pixel(target, 4, 0, 255)); // ((1000 * 10) + 30 => pixel value = 10030 => 100% |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
882 ASSERT_TRUE(TestGrayscale8Pixel(target, 5, 0, 128)); // ((2 * 10) + 30 => pixel value = 50 => 50% |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
883 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
884 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
885 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
886 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
887 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
888 TEST(ImageProcessing, ApplyWindowingFloatToGrayScale16) |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
889 { |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
890 { |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
891 Image image(PixelFormat_Float32, 6, 1, false); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
892 ImageTraits<PixelFormat_Float32>::SetFloatPixel(image, -5.0f, 0, 0); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
893 ImageTraits<PixelFormat_Float32>::SetFloatPixel(image, 0.0f, 1, 0); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
894 ImageTraits<PixelFormat_Float32>::SetFloatPixel(image, 5.0f, 2, 0); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
895 ImageTraits<PixelFormat_Float32>::SetFloatPixel(image, 10.0f, 3, 0); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
896 ImageTraits<PixelFormat_Float32>::SetFloatPixel(image, 1000.0f, 4, 0); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
897 ImageTraits<PixelFormat_Float32>::SetFloatPixel(image, 2.0f, 5, 0); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
898 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
899 { |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
900 Image target(PixelFormat_Grayscale16, 6, 1, false); |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3682
diff
changeset
|
901 ImageProcessing::ApplyWindowing_Deprecated(target, image, 5.0f, 10.0f, 1.0f, 0.0f, false); |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
902 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
903 ASSERT_TRUE(TestGrayscale16Pixel(target, 0, 0, 0)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
904 ASSERT_TRUE(TestGrayscale16Pixel(target, 1, 0, 0)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
905 ASSERT_TRUE(TestGrayscale16Pixel(target, 2, 0, 32768)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
906 ASSERT_TRUE(TestGrayscale16Pixel(target, 3, 0, 65535)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
907 ASSERT_TRUE(TestGrayscale16Pixel(target, 4, 0, 65535)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
908 ASSERT_TRUE(TestGrayscale16Pixel(target, 5, 0, 65536*2/10)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
909 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
910 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
911 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
912 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
913 TEST(ImageProcessing, ApplyWindowingGrayScale8ToGrayScale16) |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
914 { |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
915 { |
3648
eef50f5426a9
fix access to uninitialized pixels in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
916 Image image(PixelFormat_Grayscale8, 5, 1, false); |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
917 SetGrayscale8Pixel(image, 0, 0, 0); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
918 SetGrayscale8Pixel(image, 1, 0, 2); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
919 SetGrayscale8Pixel(image, 2, 0, 5); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
920 SetGrayscale8Pixel(image, 3, 0, 10); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
921 SetGrayscale8Pixel(image, 4, 0, 255); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
922 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
923 { |
3648
eef50f5426a9
fix access to uninitialized pixels in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
924 Image target(PixelFormat_Grayscale16, 5, 1, false); |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3682
diff
changeset
|
925 ImageProcessing::ApplyWindowing_Deprecated(target, image, 5.0f, 10.0f, 1.0f, 0.0f, false); |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
926 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
927 ASSERT_TRUE(TestGrayscale16Pixel(target, 0, 0, 0)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
928 ASSERT_TRUE(TestGrayscale16Pixel(target, 1, 0, 65536*2/10)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
929 ASSERT_TRUE(TestGrayscale16Pixel(target, 2, 0, 65536*5/10)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
930 ASSERT_TRUE(TestGrayscale16Pixel(target, 3, 0, 65535)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
931 ASSERT_TRUE(TestGrayscale16Pixel(target, 4, 0, 65535)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
932 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
933 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
934 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
935 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
936 TEST(ImageProcessing, ApplyWindowingGrayScale16ToGrayScale16) |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
937 { |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
938 { |
3648
eef50f5426a9
fix access to uninitialized pixels in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
939 Image image(PixelFormat_Grayscale16, 5, 1, false); |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
940 SetGrayscale16Pixel(image, 0, 0, 0); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
941 SetGrayscale16Pixel(image, 1, 0, 2); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
942 SetGrayscale16Pixel(image, 2, 0, 5); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
943 SetGrayscale16Pixel(image, 3, 0, 10); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
944 SetGrayscale16Pixel(image, 4, 0, 255); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
945 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
946 { |
3648
eef50f5426a9
fix access to uninitialized pixels in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
947 Image target(PixelFormat_Grayscale16, 5, 1, false); |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3682
diff
changeset
|
948 ImageProcessing::ApplyWindowing_Deprecated(target, image, 5.0f, 10.0f, 1.0f, 0.0f, false); |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
949 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
950 ASSERT_TRUE(TestGrayscale16Pixel(target, 0, 0, 0)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
951 ASSERT_TRUE(TestGrayscale16Pixel(target, 1, 0, 65536*2/10)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
952 ASSERT_TRUE(TestGrayscale16Pixel(target, 2, 0, 65536*5/10)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
953 ASSERT_TRUE(TestGrayscale16Pixel(target, 3, 0, 65535)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
954 ASSERT_TRUE(TestGrayscale16Pixel(target, 4, 0, 65535)); |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
955 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
956 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
957 } |
3682
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
958 |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
959 |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
960 TEST(ImageProcessing, ShiftScaleGrayscale8) |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
961 { |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
962 Image image(PixelFormat_Grayscale8, 5, 1, false); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
963 SetGrayscale8Pixel(image, 0, 0, 0); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
964 SetGrayscale8Pixel(image, 1, 0, 2); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
965 SetGrayscale8Pixel(image, 2, 0, 5); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
966 SetGrayscale8Pixel(image, 3, 0, 10); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
967 SetGrayscale8Pixel(image, 4, 0, 255); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
968 |
4056 | 969 ImageProcessing::ShiftScale(image, -1.1f, 1.5f, true); |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
970 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 0, 0)); // (0 - 1.1) * 1.5 = -1.65 ==> 0 |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
971 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 0, 1)); // (2 - 1.1) * 1.5 = 1.35 => 1 |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
972 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 0, 6)); // (5 - 1.1) * 1.5 = 5.85 => 6 |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
973 ASSERT_TRUE(TestGrayscale8Pixel(image, 3, 0, 13)); // (10 - 1.1) * 1.5 = 13.35 => 13 |
3682
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
974 ASSERT_TRUE(TestGrayscale8Pixel(image, 4, 0, 255)); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
975 } |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
976 |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
977 |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
978 TEST(ImageProcessing, ShiftScaleGrayscale16) |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
979 { |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
980 Image image(PixelFormat_Grayscale16, 5, 1, false); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
981 SetGrayscale16Pixel(image, 0, 0, 0); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
982 SetGrayscale16Pixel(image, 1, 0, 2); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
983 SetGrayscale16Pixel(image, 2, 0, 5); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
984 SetGrayscale16Pixel(image, 3, 0, 10); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
985 SetGrayscale16Pixel(image, 4, 0, 255); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
986 |
4056 | 987 ImageProcessing::ShiftScale(image, -1.1f, 1.5f, true); |
3682
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
988 ASSERT_TRUE(TestGrayscale16Pixel(image, 0, 0, 0)); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
989 ASSERT_TRUE(TestGrayscale16Pixel(image, 1, 0, 1)); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
990 ASSERT_TRUE(TestGrayscale16Pixel(image, 2, 0, 6)); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
991 ASSERT_TRUE(TestGrayscale16Pixel(image, 3, 0, 13)); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
992 ASSERT_TRUE(TestGrayscale16Pixel(image, 4, 0, 381)); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
993 } |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
994 |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
995 |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
996 TEST(ImageProcessing, ShiftScaleSignedGrayscale16) |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
997 { |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
998 Image image(PixelFormat_SignedGrayscale16, 5, 1, false); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
999 SetSignedGrayscale16Pixel(image, 0, 0, 0); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1000 SetSignedGrayscale16Pixel(image, 1, 0, 2); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1001 SetSignedGrayscale16Pixel(image, 2, 0, 5); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1002 SetSignedGrayscale16Pixel(image, 3, 0, 10); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1003 SetSignedGrayscale16Pixel(image, 4, 0, 255); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1004 |
4056 | 1005 ImageProcessing::ShiftScale(image, -17.1f, 11.5f, true); |
3682
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1006 ASSERT_TRUE(TestSignedGrayscale16Pixel(image, 0, 0, -197)); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1007 ASSERT_TRUE(TestSignedGrayscale16Pixel(image, 1, 0, -174)); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1008 ASSERT_TRUE(TestSignedGrayscale16Pixel(image, 2, 0, -139)); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1009 ASSERT_TRUE(TestSignedGrayscale16Pixel(image, 3, 0, -82)); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1010 ASSERT_TRUE(TestSignedGrayscale16Pixel(image, 4, 0, 2736)); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1011 } |
4079
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1012 |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1013 |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1014 TEST(ImageProcessing, ShiftScale2) |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1015 { |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1016 std::vector<float> va; |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1017 va.push_back(0); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1018 va.push_back(-10); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1019 va.push_back(5); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1020 |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1021 std::vector<float> vb; |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1022 vb.push_back(0); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1023 vb.push_back(-42); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1024 vb.push_back(42); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1025 |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1026 Image source(PixelFormat_Float32, 1, 1, false); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1027 ImageTraits<PixelFormat_Float32>::SetFloatPixel(source, 10, 0, 0); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1028 |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1029 for (std::vector<float>::const_iterator a = va.begin(); a != va.end(); ++a) |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1030 { |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1031 for (std::vector<float>::const_iterator b = vb.begin(); b != vb.end(); ++b) |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1032 { |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1033 Image target(PixelFormat_Float32, 1, 1, false); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1034 |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1035 ImageProcessing::Copy(target, source); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1036 ImageProcessing::ShiftScale2(target, *b, *a, false); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1037 ASSERT_FLOAT_EQ((*a) * 10.0f + (*b), |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1038 ImageTraits<PixelFormat_Float32>::GetFloatPixel(target, 0, 0)); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1039 |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1040 ImageProcessing::Copy(target, source); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1041 ImageProcessing::ShiftScale(target, *b, *a, false); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1042 ASSERT_FLOAT_EQ((*a) * (10.0f + (*b)), |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1043 ImageTraits<PixelFormat_Float32>::GetFloatPixel(target, 0, 0)); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1044 } |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1045 } |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1046 } |