Mercurial > hg > orthanc
annotate OrthancFramework/UnitTestsSources/ImageProcessingTests.cpp @ 5145:df040c83796c
correctly report ThreadedSetOfInstancesJob progress
author | Alain Mazy <am@osimis.io> |
---|---|
date | Fri, 27 Jan 2023 11:23:35 +0100 |
parents | fcdf399f9fc0 |
children | 0ea402b4d901 |
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 |
4870
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
853 | 7 * |
8 * 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
|
9 * 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
|
10 * 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
|
11 * the License, or (at your option) any later version. |
853 | 12 * |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * 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
|
16 * Lesser General Public License for more details. |
853 | 17 * |
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
|
18 * 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
|
19 * 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
|
20 * <http://www.gnu.org/licenses/>. |
853 | 21 **/ |
22 | |
23 | |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
24 #if ORTHANC_UNIT_TESTS_LINK_FRAMEWORK == 1 |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
25 // 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
|
26 # include <OrthancFramework.h> |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
27 #endif |
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
28 |
4062 | 29 #include <gtest/gtest.h> |
853 | 30 |
4045 | 31 #include "../Sources/Compatibility.h" |
32 #include "../Sources/DicomFormat/DicomImageInformation.h" | |
33 #include "../Sources/Images/Image.h" | |
34 #include "../Sources/Images/ImageProcessing.h" | |
35 #include "../Sources/Images/ImageTraits.h" | |
36 #include "../Sources/OrthancException.h" | |
2487
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
37 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
38 #include <memory> |
853 | 39 |
40 using namespace Orthanc; | |
41 | |
42 | |
855 | 43 TEST(DicomImageInformation, ExtractPixelFormat1) |
853 | 44 { |
855 | 45 // Cardiac/MR* |
46 DicomMap m; | |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
47 m.SetValue(DICOM_TAG_ROWS, "24", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
48 m.SetValue(DICOM_TAG_COLUMNS, "16", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
49 m.SetValue(DICOM_TAG_BITS_ALLOCATED, "16", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
50 m.SetValue(DICOM_TAG_SAMPLES_PER_PIXEL, "1", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
51 m.SetValue(DICOM_TAG_BITS_STORED, "12", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
52 m.SetValue(DICOM_TAG_HIGH_BIT, "11", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
53 m.SetValue(DICOM_TAG_PIXEL_REPRESENTATION, "0", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
54 m.SetValue(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2", false); |
855 | 55 |
56 DicomImageInformation info(m); | |
57 PixelFormat format; | |
1905
8b1baa2315b8
Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
58 ASSERT_TRUE(info.ExtractPixelFormat(format, false)); |
855 | 59 ASSERT_EQ(PixelFormat_Grayscale16, format); |
853 | 60 } |
855 | 61 |
62 | |
63 TEST(DicomImageInformation, ExtractPixelFormat2) | |
64 { | |
65 // Delphine CT | |
66 DicomMap m; | |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
67 m.SetValue(DICOM_TAG_ROWS, "24", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
68 m.SetValue(DICOM_TAG_COLUMNS, "16", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
69 m.SetValue(DICOM_TAG_BITS_ALLOCATED, "16", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
70 m.SetValue(DICOM_TAG_SAMPLES_PER_PIXEL, "1", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
71 m.SetValue(DICOM_TAG_BITS_STORED, "16", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
72 m.SetValue(DICOM_TAG_HIGH_BIT, "15", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
73 m.SetValue(DICOM_TAG_PIXEL_REPRESENTATION, "1", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
74 m.SetValue(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2", false); |
855 | 75 |
76 DicomImageInformation info(m); | |
77 PixelFormat format; | |
1905
8b1baa2315b8
Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
78 ASSERT_TRUE(info.ExtractPixelFormat(format, false)); |
855 | 79 ASSERT_EQ(PixelFormat_SignedGrayscale16, format); |
80 } | |
2487
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 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
84 namespace |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
85 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
86 template <typename T> |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
87 class TestImageTraits : public ::testing::Test |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
88 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
89 private: |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
90 std::unique_ptr<Image> image_; |
2487
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
91 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
92 protected: |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2487
diff
changeset
|
93 virtual void SetUp() ORTHANC_OVERRIDE |
2487
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
94 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
95 image_.reset(new Image(ImageTraits::PixelTraits::GetPixelFormat(), 7, 9, false)); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
96 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
97 |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2487
diff
changeset
|
98 virtual void TearDown() ORTHANC_OVERRIDE |
2487
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
99 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
100 image_.reset(NULL); |
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 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
103 public: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
104 typedef T ImageTraits; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
105 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
106 ImageAccessor& GetImage() |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
107 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
108 return *image_; |
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 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
112 template <typename T> |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
113 class TestIntegerImageTraits : public TestImageTraits<T> |
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 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
119 typedef ::testing::Types< |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
120 ImageTraits<PixelFormat_Grayscale8>, |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
121 ImageTraits<PixelFormat_Grayscale16>, |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
122 ImageTraits<PixelFormat_SignedGrayscale16> |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
123 > IntegerFormats; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
124 TYPED_TEST_CASE(TestIntegerImageTraits, IntegerFormats); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
125 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
126 typedef ::testing::Types< |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
127 ImageTraits<PixelFormat_Grayscale8>, |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
128 ImageTraits<PixelFormat_Grayscale16>, |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
129 ImageTraits<PixelFormat_SignedGrayscale16>, |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
130 ImageTraits<PixelFormat_RGB24>, |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
131 ImageTraits<PixelFormat_BGRA32> |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
132 > AllFormats; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
133 TYPED_TEST_CASE(TestImageTraits, AllFormats); |
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 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
136 TYPED_TEST(TestImageTraits, SetZero) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
137 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
138 ImageAccessor& image = this->GetImage(); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
139 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
140 memset(image.GetBuffer(), 128, image.GetHeight() * image.GetWidth()); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
141 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
142 switch (image.GetFormat()) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
143 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
144 case PixelFormat_Grayscale8: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
145 case PixelFormat_Grayscale16: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
146 case PixelFormat_SignedGrayscale16: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
147 ImageProcessing::Set(image, 0); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
148 break; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
149 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
150 case PixelFormat_RGB24: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
151 case PixelFormat_BGRA32: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
152 ImageProcessing::Set(image, 0, 0, 0, 0); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
153 break; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
154 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
155 default: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
156 ASSERT_TRUE(0); |
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 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
159 typename TestFixture::ImageTraits::PixelType zero, value; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
160 TestFixture::ImageTraits::PixelTraits::SetZero(zero); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
161 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
162 for (unsigned int y = 0; y < image.GetHeight(); y++) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
163 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
164 for (unsigned int x = 0; x < image.GetWidth(); x++) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
165 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
166 TestFixture::ImageTraits::GetPixel(value, image, x, y); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
167 ASSERT_TRUE(TestFixture::ImageTraits::PixelTraits::IsEqual(zero, value)); |
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 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
173 TYPED_TEST(TestIntegerImageTraits, SetZeroFloat) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
174 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
175 ImageAccessor& image = this->GetImage(); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
176 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
177 memset(image.GetBuffer(), 128, image.GetHeight() * image.GetWidth()); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
178 |
3258 | 179 float c = 0.0f; |
2487
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
180 for (unsigned int y = 0; y < image.GetHeight(); y++) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
181 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
182 for (unsigned int x = 0; x < image.GetWidth(); x++, c++) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
183 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
184 TestFixture::ImageTraits::SetFloatPixel(image, c, x, y); |
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 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
187 |
3260
345f86fd1ac3
fix (shame on me for not testing)
Alain Mazy <alain@mazy.be>
parents:
3258
diff
changeset
|
188 c = 0.0f; |
2487
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
189 for (unsigned int y = 0; y < image.GetHeight(); y++) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
190 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
191 for (unsigned int x = 0; x < image.GetWidth(); x++, c++) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
192 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
193 ASSERT_FLOAT_EQ(c, TestFixture::ImageTraits::GetFloatPixel(image, x, y)); |
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 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
196 } |
3258 | 197 |
4872
b1556cefa5c6
reimplementation from scratch of ImageProcessing::FillPolygon()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
198 |
3258 | 199 TYPED_TEST(TestIntegerImageTraits, FillPolygon) |
200 { | |
201 ImageAccessor& image = this->GetImage(); | |
202 | |
203 ImageProcessing::Set(image, 128); | |
204 | |
205 // draw a triangle | |
206 std::vector<ImageProcessing::ImagePoint> points; | |
207 points.push_back(ImageProcessing::ImagePoint(1,1)); | |
208 points.push_back(ImageProcessing::ImagePoint(1,5)); | |
209 points.push_back(ImageProcessing::ImagePoint(5,5)); | |
210 | |
3503
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
211 ImageProcessing::FillPolygon(image, points, 255); |
3258 | 212 |
213 // outside polygon | |
214 ASSERT_FLOAT_EQ(128, TestFixture::ImageTraits::GetFloatPixel(image, 0, 0)); | |
215 ASSERT_FLOAT_EQ(128, TestFixture::ImageTraits::GetFloatPixel(image, 0, 6)); | |
216 ASSERT_FLOAT_EQ(128, TestFixture::ImageTraits::GetFloatPixel(image, 6, 6)); | |
217 ASSERT_FLOAT_EQ(128, TestFixture::ImageTraits::GetFloatPixel(image, 6, 0)); | |
218 | |
3431 | 219 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 1, 1)); |
3258 | 220 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 1, 2)); |
3431 | 221 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 1, 5)); |
3258 | 222 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 2, 4)); |
3431 | 223 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 5, 5)); |
3258 | 224 } |
3365 | 225 |
3366 | 226 TYPED_TEST(TestIntegerImageTraits, FillPolygonLargerThanImage) |
3365 | 227 { |
228 ImageAccessor& image = this->GetImage(); | |
229 | |
230 ImageProcessing::Set(image, 0); | |
231 | |
232 std::vector<ImageProcessing::ImagePoint> points; | |
233 points.push_back(ImageProcessing::ImagePoint(0, 0)); | |
234 points.push_back(ImageProcessing::ImagePoint(image.GetWidth(),0)); | |
235 points.push_back(ImageProcessing::ImagePoint(image.GetWidth(),image.GetHeight())); | |
236 points.push_back(ImageProcessing::ImagePoint(0,image.GetHeight())); | |
237 | |
4872
b1556cefa5c6
reimplementation from scratch of ImageProcessing::FillPolygon()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
238 ImageProcessing::FillPolygon(image, points, 255); |
b1556cefa5c6
reimplementation from scratch of ImageProcessing::FillPolygon()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
239 |
b1556cefa5c6
reimplementation from scratch of ImageProcessing::FillPolygon()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
240 for (unsigned int y = 0; y < image.GetHeight(); y++) |
b1556cefa5c6
reimplementation from scratch of ImageProcessing::FillPolygon()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
241 { |
b1556cefa5c6
reimplementation from scratch of ImageProcessing::FillPolygon()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
242 for (unsigned int x = 0; x < image.GetWidth(); x++) |
b1556cefa5c6
reimplementation from scratch of ImageProcessing::FillPolygon()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
243 { |
b1556cefa5c6
reimplementation from scratch of ImageProcessing::FillPolygon()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
244 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, x, y)); |
b1556cefa5c6
reimplementation from scratch of ImageProcessing::FillPolygon()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
245 } |
b1556cefa5c6
reimplementation from scratch of ImageProcessing::FillPolygon()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
246 } |
3365 | 247 } |
248 | |
249 TYPED_TEST(TestIntegerImageTraits, FillPolygonFullImage) | |
250 { | |
251 ImageAccessor& image = this->GetImage(); | |
252 | |
253 ImageProcessing::Set(image, 0); | |
254 | |
255 std::vector<ImageProcessing::ImagePoint> points; | |
256 points.push_back(ImageProcessing::ImagePoint(0, 0)); | |
257 points.push_back(ImageProcessing::ImagePoint(image.GetWidth() - 1,0)); | |
258 points.push_back(ImageProcessing::ImagePoint(image.GetWidth() - 1,image.GetHeight() - 1)); | |
259 points.push_back(ImageProcessing::ImagePoint(0,image.GetHeight() - 1)); | |
260 | |
3503
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
261 ImageProcessing::FillPolygon(image, points, 255); |
3365 | 262 |
3431 | 263 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 0, 0)); |
264 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, image.GetWidth() - 1, image.GetHeight() - 1)); | |
3365 | 265 } |
3503
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 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
269 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
270 static void SetGrayscale8Pixel(ImageAccessor& image, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
271 unsigned int x, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
272 unsigned int y, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
273 uint8_t value) |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
274 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
275 ImageTraits<PixelFormat_Grayscale8>::SetPixel(image, value, x, y); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
276 } |
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 static bool TestGrayscale8Pixel(const ImageAccessor& image, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
279 unsigned int x, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
280 unsigned int y, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
281 uint8_t value) |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
282 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
283 PixelTraits<PixelFormat_Grayscale8>::PixelType p; |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
284 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
|
285 if (p != value) printf("%d %d\n", p, value); |
3503
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
286 return p == value; |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
287 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
288 |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
289 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
|
290 unsigned int x, |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
291 unsigned int y, |
3682
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
292 uint16_t value) |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
293 { |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
294 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
|
295 } |
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 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
|
298 unsigned int x, |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
299 unsigned int y, |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
300 uint16_t value) |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
301 { |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
302 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
|
303 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
|
304 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
|
305 return p == value; |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
306 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
307 |
3682
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
308 static void SetSignedGrayscale16Pixel(ImageAccessor& image, |
4875
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
309 unsigned int x, |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
310 unsigned int y, |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
311 int16_t value) |
3682
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
312 { |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
313 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
|
314 } |
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 static bool TestSignedGrayscale16Pixel(const ImageAccessor& image, |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
317 unsigned int x, |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
318 unsigned int y, |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
319 int16_t value) |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
320 { |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
321 PixelTraits<PixelFormat_SignedGrayscale16>::PixelType p; |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
322 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
|
323 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
|
324 return p == value; |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
325 } |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
326 |
3503
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
327 static void SetRGB24Pixel(ImageAccessor& image, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
328 unsigned int x, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
329 unsigned int y, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
330 uint8_t red, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
331 uint8_t green, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
332 uint8_t blue) |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
333 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
334 PixelTraits<PixelFormat_RGB24>::PixelType p; |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
335 p.red_ = red; |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
336 p.green_ = green; |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
337 p.blue_ = blue; |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
338 ImageTraits<PixelFormat_RGB24>::SetPixel(image, p, x, y); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
339 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
340 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
341 static bool TestRGB24Pixel(const ImageAccessor& image, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
342 unsigned int x, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
343 unsigned int y, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
344 uint8_t red, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
345 uint8_t green, |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
346 uint8_t blue) |
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 PixelTraits<PixelFormat_RGB24>::PixelType p; |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
349 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
|
350 bool ok = (p.red_ == red && |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
351 p.green_ == green && |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
352 p.blue_ == blue); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
353 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
|
354 return ok; |
3503
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 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
358 TEST(ImageProcessing, FlipGrayscale8) |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
359 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
360 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
361 Image image(PixelFormat_Grayscale8, 0, 0, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
362 ImageProcessing::FlipX(image); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
363 ImageProcessing::FlipY(image); |
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 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
366 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
367 Image image(PixelFormat_Grayscale8, 1, 1, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
368 SetGrayscale8Pixel(image, 0, 0, 128); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
369 ImageProcessing::FlipX(image); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
370 ImageProcessing::FlipY(image); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
371 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 0, 128)); |
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 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
374 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
375 Image image(PixelFormat_Grayscale8, 3, 2, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
376 SetGrayscale8Pixel(image, 0, 0, 10); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
377 SetGrayscale8Pixel(image, 1, 0, 20); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
378 SetGrayscale8Pixel(image, 2, 0, 30); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
379 SetGrayscale8Pixel(image, 0, 1, 40); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
380 SetGrayscale8Pixel(image, 1, 1, 50); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
381 SetGrayscale8Pixel(image, 2, 1, 60); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
382 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
383 ImageProcessing::FlipX(image); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
384 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 0, 30)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
385 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 0, 20)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
386 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 0, 10)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
387 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 1, 60)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
388 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 1, 50)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
389 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 1, 40)); |
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 ImageProcessing::FlipY(image); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
392 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 0, 60)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
393 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 0, 50)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
394 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 0, 40)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
395 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 1, 30)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
396 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 1, 20)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
397 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 1, 10)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
398 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
399 } |
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 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
402 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
403 TEST(ImageProcessing, FlipRGB24) |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
404 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
405 Image image(PixelFormat_RGB24, 2, 2, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
406 SetRGB24Pixel(image, 0, 0, 10, 100, 110); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
407 SetRGB24Pixel(image, 1, 0, 20, 100, 110); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
408 SetRGB24Pixel(image, 0, 1, 30, 100, 110); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
409 SetRGB24Pixel(image, 1, 1, 40, 100, 110); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
410 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
411 ImageProcessing::FlipX(image); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
412 ASSERT_TRUE(TestRGB24Pixel(image, 0, 0, 20, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
413 ASSERT_TRUE(TestRGB24Pixel(image, 1, 0, 10, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
414 ASSERT_TRUE(TestRGB24Pixel(image, 0, 1, 40, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
415 ASSERT_TRUE(TestRGB24Pixel(image, 1, 1, 30, 100, 110)); |
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 ImageProcessing::FlipY(image); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
418 ASSERT_TRUE(TestRGB24Pixel(image, 0, 0, 40, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
419 ASSERT_TRUE(TestRGB24Pixel(image, 1, 0, 30, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
420 ASSERT_TRUE(TestRGB24Pixel(image, 0, 1, 20, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
421 ASSERT_TRUE(TestRGB24Pixel(image, 1, 1, 10, 100, 110)); |
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 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
425 TEST(ImageProcessing, ResizeBasicGrayscale8) |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
426 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
427 Image source(PixelFormat_Grayscale8, 2, 2, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
428 SetGrayscale8Pixel(source, 0, 0, 10); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
429 SetGrayscale8Pixel(source, 1, 0, 20); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
430 SetGrayscale8Pixel(source, 0, 1, 30); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
431 SetGrayscale8Pixel(source, 1, 1, 40); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
432 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
433 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
434 Image target(PixelFormat_Grayscale8, 2, 4, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
435 ImageProcessing::Resize(target, source); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
436 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 0, 10)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
437 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 0, 20)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
438 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 1, 10)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
439 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 1, 20)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
440 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 2, 30)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
441 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 2, 40)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
442 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 3, 30)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
443 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 3, 40)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
444 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
445 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
446 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
447 Image target(PixelFormat_Grayscale8, 4, 2, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
448 ImageProcessing::Resize(target, source); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
449 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 0, 10)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
450 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 0, 10)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
451 ASSERT_TRUE(TestGrayscale8Pixel(target, 2, 0, 20)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
452 ASSERT_TRUE(TestGrayscale8Pixel(target, 3, 0, 20)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
453 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 1, 30)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
454 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 1, 30)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
455 ASSERT_TRUE(TestGrayscale8Pixel(target, 2, 1, 40)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
456 ASSERT_TRUE(TestGrayscale8Pixel(target, 3, 1, 40)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
457 } |
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 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
461 TEST(ImageProcessing, ResizeBasicRGB24) |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
462 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
463 Image source(PixelFormat_RGB24, 2, 2, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
464 SetRGB24Pixel(source, 0, 0, 10, 100, 110); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
465 SetRGB24Pixel(source, 1, 0, 20, 100, 110); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
466 SetRGB24Pixel(source, 0, 1, 30, 100, 110); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
467 SetRGB24Pixel(source, 1, 1, 40, 100, 110); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
468 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
469 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
470 Image target(PixelFormat_RGB24, 2, 4, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
471 ImageProcessing::Resize(target, source); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
472 ASSERT_TRUE(TestRGB24Pixel(target, 0, 0, 10, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
473 ASSERT_TRUE(TestRGB24Pixel(target, 1, 0, 20, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
474 ASSERT_TRUE(TestRGB24Pixel(target, 0, 1, 10, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
475 ASSERT_TRUE(TestRGB24Pixel(target, 1, 1, 20, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
476 ASSERT_TRUE(TestRGB24Pixel(target, 0, 2, 30, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
477 ASSERT_TRUE(TestRGB24Pixel(target, 1, 2, 40, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
478 ASSERT_TRUE(TestRGB24Pixel(target, 0, 3, 30, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
479 ASSERT_TRUE(TestRGB24Pixel(target, 1, 3, 40, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
480 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
481 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
482 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
483 Image target(PixelFormat_RGB24, 4, 2, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
484 ImageProcessing::Resize(target, source); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
485 ASSERT_TRUE(TestRGB24Pixel(target, 0, 0, 10, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
486 ASSERT_TRUE(TestRGB24Pixel(target, 1, 0, 10, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
487 ASSERT_TRUE(TestRGB24Pixel(target, 2, 0, 20, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
488 ASSERT_TRUE(TestRGB24Pixel(target, 3, 0, 20, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
489 ASSERT_TRUE(TestRGB24Pixel(target, 0, 1, 30, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
490 ASSERT_TRUE(TestRGB24Pixel(target, 1, 1, 30, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
491 ASSERT_TRUE(TestRGB24Pixel(target, 2, 1, 40, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
492 ASSERT_TRUE(TestRGB24Pixel(target, 3, 1, 40, 100, 110)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
493 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
494 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
495 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
496 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
497 TEST(ImageProcessing, ResizeEmptyGrayscale8) |
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, 0, 0, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
501 Image target(PixelFormat_Grayscale8, 2, 2, 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 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 0, 0)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
504 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 0, 0)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
505 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 1, 0)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
506 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 1, 0)); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
507 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
508 |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
509 { |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
510 Image source(PixelFormat_Grayscale8, 2, 2, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
511 Image target(PixelFormat_Grayscale8, 0, 0, false); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
512 ImageProcessing::Resize(target, source); |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
513 } |
46cf170ba121
ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3431
diff
changeset
|
514 } |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
515 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
516 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
517 TEST(ImageProcessing, Convolution) |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
518 { |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
519 std::vector<float> k1(5, 1); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
520 std::vector<float> k2(1, 1); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
521 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
522 { |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
523 Image image(PixelFormat_Grayscale8, 1, 1, false); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
524 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
|
525 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
|
526 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
|
527 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
|
528 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
|
529 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
|
530 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
|
531 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
|
532 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 0, 100)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
533 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
534 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
535 { |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
536 Image image(PixelFormat_RGB24, 1, 1, false); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
537 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
|
538 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
|
539 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
|
540 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
|
541 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
|
542 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
|
543 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
|
544 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
|
545 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
|
546 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
547 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
548 { |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
549 Image dirac(PixelFormat_Grayscale8, 9, 1, false); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
550 ImageProcessing::Set(dirac, 0); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
551 SetGrayscale8Pixel(dirac, 4, 0, 100); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
552 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
553 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
554 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
|
555 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
|
556 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
557 ASSERT_TRUE(TestGrayscale8Pixel(*image, 1, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
558 ASSERT_TRUE(TestGrayscale8Pixel(*image, 2, 0, 20)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
559 ASSERT_TRUE(TestGrayscale8Pixel(*image, 3, 0, 20)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
560 ASSERT_TRUE(TestGrayscale8Pixel(*image, 4, 0, 20)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
561 ASSERT_TRUE(TestGrayscale8Pixel(*image, 5, 0, 20)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
562 ASSERT_TRUE(TestGrayscale8Pixel(*image, 6, 0, 20)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
563 ASSERT_TRUE(TestGrayscale8Pixel(*image, 7, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
564 ASSERT_TRUE(TestGrayscale8Pixel(*image, 8, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
565 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
566 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
567 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
568 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
|
569 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
|
570 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
571 ASSERT_TRUE(TestGrayscale8Pixel(*image, 1, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
572 ASSERT_TRUE(TestGrayscale8Pixel(*image, 2, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
573 ASSERT_TRUE(TestGrayscale8Pixel(*image, 3, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
574 ASSERT_TRUE(TestGrayscale8Pixel(*image, 4, 0, 100)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
575 ASSERT_TRUE(TestGrayscale8Pixel(*image, 5, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
576 ASSERT_TRUE(TestGrayscale8Pixel(*image, 6, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
577 ASSERT_TRUE(TestGrayscale8Pixel(*image, 7, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
578 ASSERT_TRUE(TestGrayscale8Pixel(*image, 8, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
579 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
580 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
581 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
582 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
|
583 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
|
584 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
585 ASSERT_TRUE(TestGrayscale8Pixel(*image, 1, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
586 ASSERT_TRUE(TestGrayscale8Pixel(*image, 2, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
587 ASSERT_TRUE(TestGrayscale8Pixel(*image, 3, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
588 ASSERT_TRUE(TestGrayscale8Pixel(*image, 4, 0, 100)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
589 ASSERT_TRUE(TestGrayscale8Pixel(*image, 5, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
590 ASSERT_TRUE(TestGrayscale8Pixel(*image, 6, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
591 ASSERT_TRUE(TestGrayscale8Pixel(*image, 7, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
592 ASSERT_TRUE(TestGrayscale8Pixel(*image, 8, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
593 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
594 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
595 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
596 { |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
597 Image dirac(PixelFormat_Grayscale8, 1, 9, false); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
598 ImageProcessing::Set(dirac, 0); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
599 SetGrayscale8Pixel(dirac, 0, 4, 100); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
600 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
601 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
602 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
|
603 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
|
604 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
605 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 1, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
606 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 2, 20)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
607 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 3, 20)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
608 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 4, 20)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
609 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 5, 20)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
610 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 6, 20)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
611 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 7, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
612 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 8, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
613 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
614 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
615 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
616 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
|
617 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
|
618 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
619 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 1, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
620 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 2, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
621 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 3, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
622 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 4, 100)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
623 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 5, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
624 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 6, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
625 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 7, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
626 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 8, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
627 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
628 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
629 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
630 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
|
631 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
|
632 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
633 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 1, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
634 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 2, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
635 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 3, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
636 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 4, 100)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
637 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 5, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
638 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 6, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
639 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 7, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
640 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 8, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
641 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
642 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
643 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
644 { |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
645 Image dirac(PixelFormat_RGB24, 9, 1, false); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
646 ImageProcessing::Set(dirac, 0); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
647 SetRGB24Pixel(dirac, 4, 0, 100, 120, 140); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
648 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
649 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
650 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
|
651 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
|
652 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
|
653 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
|
654 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
|
655 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
|
656 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
|
657 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
|
658 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
|
659 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
|
660 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
|
661 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
662 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
663 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
664 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
|
665 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
|
666 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
|
667 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
|
668 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
|
669 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
|
670 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
|
671 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
|
672 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
|
673 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
|
674 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
|
675 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
676 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
677 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
678 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
|
679 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
|
680 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
|
681 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
|
682 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
|
683 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
|
684 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
|
685 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
|
686 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
|
687 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
|
688 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
|
689 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
690 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
691 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
692 { |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
693 Image dirac(PixelFormat_RGB24, 1, 9, false); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
694 ImageProcessing::Set(dirac, 0); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
695 SetRGB24Pixel(dirac, 0, 4, 100, 120, 140); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
696 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
697 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
698 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
|
699 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
|
700 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
|
701 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
|
702 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
|
703 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
|
704 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
|
705 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
|
706 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
|
707 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
|
708 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
|
709 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
710 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
711 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
712 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
|
713 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
|
714 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
|
715 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
|
716 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
|
717 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
|
718 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
|
719 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
|
720 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
|
721 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
|
722 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
|
723 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
724 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
725 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
726 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
|
727 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
|
728 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
|
729 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
|
730 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
|
731 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
|
732 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
|
733 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
|
734 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
|
735 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
|
736 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
|
737 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
738 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
739 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
740 |
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 TEST(ImageProcessing, SmoothGaussian5x5) |
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 /** |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
745 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
|
746 g1 = [ 1 4 6 4 1 ]; |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
747 g1 /= sum(g1); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
748 g2 = conv2(g1, g1'); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
749 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
|
750 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
|
751 **/ |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
752 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
753 { |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
754 Image image(PixelFormat_Grayscale8, 5, 5, false); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
755 ImageProcessing::Set(image, 0); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
756 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
|
757 ImageProcessing::SmoothGaussian5x5(image, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
758 |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
759 // 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
|
760 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
|
761 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
|
762 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
|
763 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
|
764 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
|
765 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
|
766 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 1, 6)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
767 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 1, 9)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
768 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
|
769 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
|
770 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 2, 2)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
771 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 2, 9)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
772 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 2, 14)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
773 ASSERT_TRUE(TestGrayscale8Pixel(image, 3, 2, 9)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
774 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
|
775 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
|
776 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 3, 6)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
777 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 3, 9)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
778 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
|
779 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
|
780 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
|
781 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
|
782 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
|
783 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
|
784 ASSERT_TRUE(TestGrayscale8Pixel(image, 4, 4, 0)); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
785 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
786 |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
787 { |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
788 Image image(PixelFormat_RGB24, 5, 5, false); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
789 ImageProcessing::Set(image, 0); |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
790 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
|
791 ImageProcessing::SmoothGaussian5x5(image, true /* round */); |
3504
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
792 |
4065
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
793 // In Octave: |
d6362b2c4b61
export dcmdata in shared library, rounding in convolution tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
794 // 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
|
795 // 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
|
796 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
|
797 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
|
798 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
|
799 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
|
800 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
|
801 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
|
802 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
|
803 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
|
804 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
|
805 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
|
806 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
|
807 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
|
808 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
|
809 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
|
810 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
|
811 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
|
812 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
|
813 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
|
814 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
|
815 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
|
816 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
|
817 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
|
818 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
|
819 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
|
820 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
|
821 } |
18566f9e1831
unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3503
diff
changeset
|
822 } |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
823 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
824 TEST(ImageProcessing, ApplyWindowingFloatToGrayScale8) |
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 { |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
827 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
|
828 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
|
829 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
|
830 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
|
831 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
|
832 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
|
833 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
|
834 |
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 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
|
837 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
|
838 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
839 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
|
840 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
|
841 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
|
842 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
|
843 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
|
844 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
|
845 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
846 |
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 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
|
849 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
|
850 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
851 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
|
852 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
|
853 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
|
854 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
|
855 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
|
856 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
|
857 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
858 |
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 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
|
861 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
|
862 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
863 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
|
864 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
|
865 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
|
866 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
|
867 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
|
868 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
|
869 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
870 |
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 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
|
873 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
|
874 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
875 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
|
876 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
|
877 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
|
878 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
|
879 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
|
880 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
|
881 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
882 |
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 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
|
885 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
|
886 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
887 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
|
888 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
|
889 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
|
890 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
|
891 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
|
892 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
|
893 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
894 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
895 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
896 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
897 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
898 TEST(ImageProcessing, ApplyWindowingFloatToGrayScale16) |
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 { |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
901 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
|
902 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
|
903 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
|
904 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
|
905 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
|
906 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
|
907 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
|
908 |
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 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
|
911 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
|
912 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
913 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
|
914 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
|
915 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
|
916 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
|
917 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
|
918 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
|
919 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
920 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
921 } |
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 TEST(ImageProcessing, ApplyWindowingGrayScale8ToGrayScale16) |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
924 { |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
925 { |
3648
eef50f5426a9
fix access to uninitialized pixels in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
926 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
|
927 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
|
928 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
|
929 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
|
930 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
|
931 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
|
932 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
933 { |
3648
eef50f5426a9
fix access to uninitialized pixels in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
934 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
|
935 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
|
936 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
937 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
|
938 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
|
939 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
|
940 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
|
941 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
|
942 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
943 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
944 } |
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 TEST(ImageProcessing, ApplyWindowingGrayScale16ToGrayScale16) |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
947 { |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
948 { |
3648
eef50f5426a9
fix access to uninitialized pixels in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
949 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
|
950 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
|
951 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
|
952 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
|
953 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
|
954 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
|
955 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
956 { |
3648
eef50f5426a9
fix access to uninitialized pixels in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
957 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
|
958 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
|
959 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
960 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
|
961 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
|
962 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
|
963 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
|
964 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
|
965 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
966 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3504
diff
changeset
|
967 } |
3682
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
968 |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
969 |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
970 TEST(ImageProcessing, ShiftScaleGrayscale8) |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
971 { |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
972 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
|
973 SetGrayscale8Pixel(image, 0, 0, 0); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
974 SetGrayscale8Pixel(image, 1, 0, 2); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
975 SetGrayscale8Pixel(image, 2, 0, 5); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
976 SetGrayscale8Pixel(image, 3, 0, 10); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
977 SetGrayscale8Pixel(image, 4, 0, 255); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
978 |
4056 | 979 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
|
980 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
|
981 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
|
982 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
|
983 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
|
984 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
|
985 } |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
986 |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
987 |
4780
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
988 TEST(ImageProcessing, Grayscale8_Identity) |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
989 { |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
990 Image image(PixelFormat_Float32, 5, 1, false); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
991 ImageTraits<PixelFormat_Float32>::SetPixel(image, 0, 0, 0); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
992 ImageTraits<PixelFormat_Float32>::SetPixel(image, 2.5, 1, 0); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
993 ImageTraits<PixelFormat_Float32>::SetPixel(image, 5.5, 2, 0); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
994 ImageTraits<PixelFormat_Float32>::SetPixel(image, 10.5, 3, 0); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
995 ImageTraits<PixelFormat_Float32>::SetPixel(image, 255.5, 4, 0); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
996 |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
997 Image image2(PixelFormat_Grayscale8, 5, 1, false); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
998 ImageProcessing::ShiftScale(image2, image, 0, 1, false); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
999 ASSERT_TRUE(TestGrayscale8Pixel(image2, 0, 0, 0)); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1000 ASSERT_TRUE(TestGrayscale8Pixel(image2, 1, 0, 2)); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1001 ASSERT_TRUE(TestGrayscale8Pixel(image2, 2, 0, 5)); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1002 ASSERT_TRUE(TestGrayscale8Pixel(image2, 3, 0, 10)); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1003 ASSERT_TRUE(TestGrayscale8Pixel(image2, 4, 0, 255)); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1004 } |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1005 |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1006 |
3682
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1007 TEST(ImageProcessing, ShiftScaleGrayscale16) |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1008 { |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1009 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
|
1010 SetGrayscale16Pixel(image, 0, 0, 0); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1011 SetGrayscale16Pixel(image, 1, 0, 2); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1012 SetGrayscale16Pixel(image, 2, 0, 5); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1013 SetGrayscale16Pixel(image, 3, 0, 10); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1014 SetGrayscale16Pixel(image, 4, 0, 255); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1015 |
4056 | 1016 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
|
1017 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
|
1018 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
|
1019 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
|
1020 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
|
1021 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
|
1022 } |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1023 |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1024 |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1025 TEST(ImageProcessing, ShiftScaleSignedGrayscale16) |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1026 { |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1027 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
|
1028 SetSignedGrayscale16Pixel(image, 0, 0, 0); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1029 SetSignedGrayscale16Pixel(image, 1, 0, 2); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1030 SetSignedGrayscale16Pixel(image, 2, 0, 5); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1031 SetSignedGrayscale16Pixel(image, 3, 0, 10); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1032 SetSignedGrayscale16Pixel(image, 4, 0, 255); |
5f64c866108a
merging implementations of ImageProcessing::ShiftScale() and ApplyWindowing()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3648
diff
changeset
|
1033 |
4056 | 1034 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
|
1035 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
|
1036 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
|
1037 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
|
1038 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
|
1039 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
|
1040 } |
4079
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1041 |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1042 |
4780
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1043 TEST(ImageProcessing, ShiftScaleSignedGrayscale16_Identity) |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1044 { |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1045 Image image(PixelFormat_SignedGrayscale16, 5, 1, false); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1046 SetSignedGrayscale16Pixel(image, 0, 0, 0); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1047 SetSignedGrayscale16Pixel(image, 1, 0, 2); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1048 SetSignedGrayscale16Pixel(image, 2, 0, 5); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1049 SetSignedGrayscale16Pixel(image, 3, 0, 10); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1050 SetSignedGrayscale16Pixel(image, 4, 0, 255); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1051 |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1052 ImageProcessing::ShiftScale(image, 0, 1, true); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1053 ASSERT_TRUE(TestSignedGrayscale16Pixel(image, 0, 0, 0)); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1054 ASSERT_TRUE(TestSignedGrayscale16Pixel(image, 1, 0, 2)); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1055 ASSERT_TRUE(TestSignedGrayscale16Pixel(image, 2, 0, 5)); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1056 ASSERT_TRUE(TestSignedGrayscale16Pixel(image, 3, 0, 10)); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1057 ASSERT_TRUE(TestSignedGrayscale16Pixel(image, 4, 0, 255)); |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1058 } |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1059 |
ebb801d44e06
optimization in ImageProcessing::ShiftScale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1060 |
4974
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1061 TEST(ImageProcessing, ShiftFloatBuggy) |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1062 { |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1063 // This test failed in Orthanc 1.10.1 |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1064 |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1065 Image image(PixelFormat_Float32, 3, 1, false); |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1066 ImageTraits<PixelFormat_Float32>::SetFloatPixel(image, -1.0f, 0, 0); |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1067 ImageTraits<PixelFormat_Float32>::SetFloatPixel(image, 0.0f, 1, 0); |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1068 ImageTraits<PixelFormat_Float32>::SetFloatPixel(image, 1.0f, 2, 0); |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1069 |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1070 std::unique_ptr<Image> cloned(Image::Clone(image)); |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1071 |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1072 ImageProcessing::ShiftScale2(image, 0, 0.000539, true); |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1073 ASSERT_FLOAT_EQ(-0.000539f, ImageTraits<PixelFormat_Float32>::GetFloatPixel(image, 0, 0)); |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1074 ASSERT_FLOAT_EQ(0.0f, ImageTraits<PixelFormat_Float32>::GetFloatPixel(image, 1, 0)); |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1075 ASSERT_FLOAT_EQ(0.000539f, ImageTraits<PixelFormat_Float32>::GetFloatPixel(image, 2, 0)); |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1076 |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1077 ImageProcessing::ShiftScale2(*cloned, 0, 0.000539, false); |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1078 ASSERT_FLOAT_EQ(-0.000539f, ImageTraits<PixelFormat_Float32>::GetFloatPixel(*cloned, 0, 0)); |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1079 ASSERT_FLOAT_EQ(0.0f, ImageTraits<PixelFormat_Float32>::GetFloatPixel(*cloned, 1, 0)); |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1080 ASSERT_FLOAT_EQ(0.000539f, ImageTraits<PixelFormat_Float32>::GetFloatPixel(*cloned, 2, 0)); |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1081 } |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1082 |
fcdf399f9fc0
fix ImageProcessing::ShiftScale2() on floating-point images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4958
diff
changeset
|
1083 |
4079
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1084 TEST(ImageProcessing, ShiftScale2) |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1085 { |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1086 std::vector<float> va; |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1087 va.push_back(0); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1088 va.push_back(-10); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1089 va.push_back(5); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1090 |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1091 std::vector<float> vb; |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1092 vb.push_back(0); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1093 vb.push_back(-42); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1094 vb.push_back(42); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1095 |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1096 Image source(PixelFormat_Float32, 1, 1, false); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1097 ImageTraits<PixelFormat_Float32>::SetFloatPixel(source, 10, 0, 0); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1098 |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1099 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
|
1100 { |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1101 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
|
1102 { |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1103 Image target(PixelFormat_Float32, 1, 1, false); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1104 |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1105 ImageProcessing::Copy(target, source); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1106 ImageProcessing::ShiftScale2(target, *b, *a, false); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1107 ASSERT_FLOAT_EQ((*a) * 10.0f + (*b), |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1108 ImageTraits<PixelFormat_Float32>::GetFloatPixel(target, 0, 0)); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1109 |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1110 ImageProcessing::Copy(target, source); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1111 ImageProcessing::ShiftScale(target, *b, *a, false); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1112 ASSERT_FLOAT_EQ((*a) * (10.0f + (*b)), |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1113 ImageTraits<PixelFormat_Float32>::GetFloatPixel(target, 0, 0)); |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1114 } |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1115 } |
73c22208272f
ImageProcessing::ShiftScale2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
1116 } |
4875
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1117 |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1118 |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1119 namespace |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1120 { |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1121 class PolygonSegments : public ImageProcessing::IPolygonFiller |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1122 { |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1123 private: |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1124 std::vector<int> y_, x1_, x2_; |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1125 |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1126 public: |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1127 virtual void Fill(int y, |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1128 int x1, |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1129 int x2) ORTHANC_OVERRIDE |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1130 { |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1131 assert(x1 <= x2); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1132 y_.push_back(y); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1133 x1_.push_back(x1); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1134 x2_.push_back(x2); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1135 } |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1136 |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1137 size_t GetSize() const |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1138 { |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1139 return y_.size(); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1140 } |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1141 |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1142 int GetY(size_t i) const |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1143 { |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1144 return y_[i]; |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1145 } |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1146 |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1147 int GetX1(size_t i) const |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1148 { |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1149 return x1_[i]; |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1150 } |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1151 |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1152 int GetX2(size_t i) const |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1153 { |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1154 return x2_[i]; |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1155 } |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1156 }; |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1157 } |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1158 |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1159 |
4878
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1160 static bool LookupSegment(unsigned int& x1, |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1161 unsigned int& x2, |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1162 const Orthanc::ImageAccessor& image, |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1163 unsigned int y) |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1164 { |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1165 const uint8_t* p = reinterpret_cast<const uint8_t*>(image.GetConstRow(y)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1166 |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1167 bool allZeros = true; |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1168 for (unsigned int i = 0; i < image.GetWidth(); i++) |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1169 { |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1170 if (p[i] == 255) |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1171 { |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1172 allZeros = false; |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1173 break; |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1174 } |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1175 else if (p[i] > 0) |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1176 { |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1177 return false; // error |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1178 } |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1179 } |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1180 |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1181 if (allZeros) |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1182 { |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1183 return false; |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1184 } |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1185 |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1186 x1 = 0; |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1187 while (p[x1] == 0) |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1188 { |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1189 x1++; |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1190 } |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1191 |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1192 x2 = image.GetWidth() - 1; |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1193 while (p[x2] == 0) |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1194 { |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1195 x2--; |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1196 } |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1197 |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1198 for (unsigned int i = x1; i <= x2; i++) |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1199 { |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1200 if (p[i] != 255) |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1201 { |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1202 return false; |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1203 } |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1204 } |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1205 |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1206 return true; |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1207 } |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1208 |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1209 |
4875
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1210 TEST(ImageProcessing, FillPolygon) |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1211 { |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1212 { |
4878
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1213 // Empty |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1214 std::vector<ImageProcessing::ImagePoint> polygon; |
4875
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1215 |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1216 PolygonSegments segments; |
4878
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1217 ImageProcessing::FillPolygon(segments, polygon); |
4875
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1218 ASSERT_EQ(0u, segments.GetSize()); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1219 } |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1220 |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1221 { |
4878
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1222 // One point |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1223 std::vector<ImageProcessing::ImagePoint> polygon; |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1224 polygon.push_back(ImageProcessing::ImagePoint(288, 208)); |
4875
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1225 |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1226 PolygonSegments segments; |
4878
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1227 ImageProcessing::FillPolygon(segments, polygon); |
4875
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1228 ASSERT_EQ(0u, segments.GetSize()); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1229 } |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1230 |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1231 { |
4878
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1232 // One horizontal segment |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1233 std::vector<ImageProcessing::ImagePoint> polygon; |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1234 polygon.push_back(ImageProcessing::ImagePoint(10, 100)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1235 polygon.push_back(ImageProcessing::ImagePoint(50, 100)); |
4875
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1236 |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1237 PolygonSegments segments; |
4878
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1238 ImageProcessing::FillPolygon(segments, polygon); |
4875
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1239 ASSERT_EQ(1u, segments.GetSize()); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1240 ASSERT_EQ(100, segments.GetY(0)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1241 ASSERT_EQ(10, segments.GetX1(0)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1242 ASSERT_EQ(50, segments.GetX2(0)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1243 } |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1244 |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1245 { |
4878
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1246 // Set of horizontal segments |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1247 std::vector<ImageProcessing::ImagePoint> polygon; |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1248 polygon.push_back(ImageProcessing::ImagePoint(10, 100)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1249 polygon.push_back(ImageProcessing::ImagePoint(20, 100)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1250 polygon.push_back(ImageProcessing::ImagePoint(30, 100)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1251 polygon.push_back(ImageProcessing::ImagePoint(50, 100)); |
4875
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1252 |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1253 PolygonSegments segments; |
4878
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1254 ImageProcessing::FillPolygon(segments, polygon); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1255 ASSERT_EQ(1u, segments.GetSize()); |
4875
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1256 ASSERT_EQ(100, segments.GetY(0)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1257 ASSERT_EQ(10, segments.GetX1(0)); |
4878
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1258 ASSERT_EQ(50, segments.GetX2(0)); |
4875
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1259 } |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1260 |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1261 { |
4878
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1262 // Set of vertical segments |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1263 std::vector<ImageProcessing::ImagePoint> polygon; |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1264 polygon.push_back(ImageProcessing::ImagePoint(10, 100)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1265 polygon.push_back(ImageProcessing::ImagePoint(10, 102)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1266 polygon.push_back(ImageProcessing::ImagePoint(10, 105)); |
4875
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1267 |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1268 PolygonSegments segments; |
4878
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1269 ImageProcessing::FillPolygon(segments, polygon); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1270 ASSERT_EQ(6u, segments.GetSize()); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1271 for (size_t i = 0; i < segments.GetSize(); i++) |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1272 { |
4958
924b15d983c7
fix signs in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4878
diff
changeset
|
1273 ASSERT_EQ(100 + static_cast<int>(i), segments.GetY(i)); |
4878
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1274 ASSERT_EQ(10, segments.GetX1(i)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1275 ASSERT_EQ(10, segments.GetX2(i)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1276 } |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1277 } |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1278 |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1279 { |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1280 // One diagonal segment |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1281 std::vector<ImageProcessing::ImagePoint> polygon; |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1282 polygon.push_back(ImageProcessing::ImagePoint(10, 100)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1283 polygon.push_back(ImageProcessing::ImagePoint(11, 101)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1284 polygon.push_back(ImageProcessing::ImagePoint(13, 103)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1285 |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1286 PolygonSegments segments; |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1287 ImageProcessing::FillPolygon(segments, polygon); |
4875
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1288 ASSERT_EQ(4u, segments.GetSize()); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1289 ASSERT_EQ(100, segments.GetY(0)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1290 ASSERT_EQ(10, segments.GetX1(0)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1291 ASSERT_EQ(10, segments.GetX2(0)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1292 ASSERT_EQ(101, segments.GetY(1)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1293 ASSERT_EQ(11, segments.GetX1(1)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1294 ASSERT_EQ(11, segments.GetX2(1)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1295 ASSERT_EQ(102, segments.GetY(2)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1296 ASSERT_EQ(12, segments.GetX1(2)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1297 ASSERT_EQ(12, segments.GetX2(2)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1298 ASSERT_EQ(103, segments.GetY(3)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1299 ASSERT_EQ(13, segments.GetX1(3)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1300 ASSERT_EQ(13, segments.GetX2(3)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1301 } |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1302 |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1303 { |
4878
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1304 // "M" shape |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1305 std::vector<ImageProcessing::ImagePoint> polygon; |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1306 polygon.push_back(ImageProcessing::ImagePoint(5, 5)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1307 polygon.push_back(ImageProcessing::ImagePoint(7, 7)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1308 polygon.push_back(ImageProcessing::ImagePoint(9, 5)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1309 polygon.push_back(ImageProcessing::ImagePoint(9, 8)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1310 polygon.push_back(ImageProcessing::ImagePoint(5, 8)); |
4875
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1311 |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1312 PolygonSegments segments; |
4878
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1313 ImageProcessing::FillPolygon(segments, polygon); |
4875
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1314 ASSERT_EQ(6u, segments.GetSize()); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1315 ASSERT_EQ(5, segments.GetY(0)); ASSERT_EQ(5, segments.GetX1(0)); ASSERT_EQ(5, segments.GetX2(0)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1316 ASSERT_EQ(5, segments.GetY(1)); ASSERT_EQ(9, segments.GetX1(1)); ASSERT_EQ(9, segments.GetX2(1)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1317 ASSERT_EQ(6, segments.GetY(2)); ASSERT_EQ(5, segments.GetX1(2)); ASSERT_EQ(6, segments.GetX2(2)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1318 ASSERT_EQ(6, segments.GetY(3)); ASSERT_EQ(8, segments.GetX1(3)); ASSERT_EQ(9, segments.GetX2(3)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1319 ASSERT_EQ(7, segments.GetY(4)); ASSERT_EQ(5, segments.GetX1(4)); ASSERT_EQ(9, segments.GetX2(4)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1320 ASSERT_EQ(8, segments.GetY(5)); ASSERT_EQ(5, segments.GetX1(5)); ASSERT_EQ(9, segments.GetX2(5)); |
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1321 } |
4878
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1322 |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1323 { |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1324 // Rectangle |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1325 std::vector<ImageProcessing::ImagePoint> polygon; |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1326 polygon.push_back(ImageProcessing::ImagePoint(10, 50)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1327 polygon.push_back(ImageProcessing::ImagePoint(200, 50)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1328 polygon.push_back(ImageProcessing::ImagePoint(200, 100)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1329 polygon.push_back(ImageProcessing::ImagePoint(10, 100)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1330 |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1331 PolygonSegments segments; |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1332 ImageProcessing::FillPolygon(segments, polygon); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1333 ASSERT_EQ(51u, segments.GetSize()); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1334 |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1335 for (size_t i = 0; i < segments.GetSize(); i++) |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1336 { |
4958
924b15d983c7
fix signs in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4878
diff
changeset
|
1337 ASSERT_EQ(50 + static_cast<int>(i), segments.GetY(i)); |
4878
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1338 ASSERT_EQ(10, segments.GetX1(i)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1339 ASSERT_EQ(200, segments.GetX2(i)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1340 } |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1341 } |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1342 |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1343 { |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1344 // Shape that goes outside of the image on the 4 borders |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1345 std::vector<ImageProcessing::ImagePoint> polygon; |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1346 polygon.push_back(ImageProcessing::ImagePoint(5, -5)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1347 polygon.push_back(ImageProcessing::ImagePoint(40, 15)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1348 polygon.push_back(ImageProcessing::ImagePoint(20, 32)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1349 polygon.push_back(ImageProcessing::ImagePoint(-5, 27)); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1350 |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1351 Image image(PixelFormat_Grayscale8, 30, 30, false); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1352 ImageProcessing::Set(image, 0); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1353 ImageProcessing::FillPolygon(image, polygon, 255); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1354 |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1355 unsigned int x1, x2; |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1356 ASSERT_TRUE(LookupSegment(x1, x2, image, 0)); ASSERT_EQ(3u, x1); ASSERT_EQ(14u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1357 ASSERT_TRUE(LookupSegment(x1, x2, image, 1)); ASSERT_EQ(3u, x1); ASSERT_EQ(16u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1358 ASSERT_TRUE(LookupSegment(x1, x2, image, 2)); ASSERT_EQ(2u, x1); ASSERT_EQ(18u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1359 ASSERT_TRUE(LookupSegment(x1, x2, image, 3)); ASSERT_EQ(2u, x1); ASSERT_EQ(19u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1360 ASSERT_TRUE(LookupSegment(x1, x2, image, 4)); ASSERT_EQ(2u, x1); ASSERT_EQ(21u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1361 ASSERT_TRUE(LookupSegment(x1, x2, image, 5)); ASSERT_EQ(1u, x1); ASSERT_EQ(23u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1362 ASSERT_TRUE(LookupSegment(x1, x2, image, 6)); ASSERT_EQ(1u, x1); ASSERT_EQ(25u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1363 ASSERT_TRUE(LookupSegment(x1, x2, image, 7)); ASSERT_EQ(1u, x1); ASSERT_EQ(26u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1364 ASSERT_TRUE(LookupSegment(x1, x2, image, 8)); ASSERT_EQ(0u, x1); ASSERT_EQ(28u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1365 ASSERT_TRUE(LookupSegment(x1, x2, image, 9)); ASSERT_EQ(0u, x1); ASSERT_EQ(29u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1366 ASSERT_TRUE(LookupSegment(x1, x2, image, 10)); ASSERT_EQ(0u, x1); ASSERT_EQ(29u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1367 ASSERT_TRUE(LookupSegment(x1, x2, image, 11)); ASSERT_EQ(0u, x1); ASSERT_EQ(29u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1368 ASSERT_TRUE(LookupSegment(x1, x2, image, 12)); ASSERT_EQ(0u, x1); ASSERT_EQ(29u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1369 ASSERT_TRUE(LookupSegment(x1, x2, image, 13)); ASSERT_EQ(0u, x1); ASSERT_EQ(29u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1370 ASSERT_TRUE(LookupSegment(x1, x2, image, 14)); ASSERT_EQ(0u, x1); ASSERT_EQ(29u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1371 ASSERT_TRUE(LookupSegment(x1, x2, image, 15)); ASSERT_EQ(0u, x1); ASSERT_EQ(29u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1372 ASSERT_TRUE(LookupSegment(x1, x2, image, 16)); ASSERT_EQ(0u, x1); ASSERT_EQ(29u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1373 ASSERT_TRUE(LookupSegment(x1, x2, image, 17)); ASSERT_EQ(0u, x1); ASSERT_EQ(29u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1374 ASSERT_TRUE(LookupSegment(x1, x2, image, 18)); ASSERT_EQ(0u, x1); ASSERT_EQ(29u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1375 ASSERT_TRUE(LookupSegment(x1, x2, image, 19)); ASSERT_EQ(0u, x1); ASSERT_EQ(29u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1376 ASSERT_TRUE(LookupSegment(x1, x2, image, 20)); ASSERT_EQ(0u, x1); ASSERT_EQ(29u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1377 ASSERT_TRUE(LookupSegment(x1, x2, image, 21)); ASSERT_EQ(0u, x1); ASSERT_EQ(29u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1378 ASSERT_TRUE(LookupSegment(x1, x2, image, 22)); ASSERT_EQ(0u, x1); ASSERT_EQ(29u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1379 ASSERT_TRUE(LookupSegment(x1, x2, image, 23)); ASSERT_EQ(0u, x1); ASSERT_EQ(29u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1380 ASSERT_TRUE(LookupSegment(x1, x2, image, 24)); ASSERT_EQ(0u, x1); ASSERT_EQ(29u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1381 ASSERT_TRUE(LookupSegment(x1, x2, image, 25)); ASSERT_EQ(0u, x1); ASSERT_EQ(29u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1382 ASSERT_TRUE(LookupSegment(x1, x2, image, 26)); ASSERT_EQ(0u, x1); ASSERT_EQ(28u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1383 ASSERT_TRUE(LookupSegment(x1, x2, image, 27)); ASSERT_EQ(0u, x1); ASSERT_EQ(26u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1384 ASSERT_TRUE(LookupSegment(x1, x2, image, 28)); ASSERT_EQ(0u, x1); ASSERT_EQ(25u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1385 ASSERT_TRUE(LookupSegment(x1, x2, image, 29)); ASSERT_EQ(5u, x1); ASSERT_EQ(24u, x2); |
664e383b68ad
more unit tests for polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4875
diff
changeset
|
1386 } |
4875
5dae41084ab7
fix filling polygons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4872
diff
changeset
|
1387 } |