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