Mercurial > hg > orthanc
annotate UnitTestsSources/ImageProcessingTests.cpp @ 2585:4c809711149e jobs
reorganization
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 14 May 2018 21:24:51 +0200 |
parents | be1dbb1dcdd6 |
children | 22524fd06225 |
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 |
2447
878b59270859
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
853 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
11 * | |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
23 * | |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
33 | |
34 #include "PrecompiledHeadersUnitTests.h" | |
35 #include "gtest/gtest.h" | |
36 | |
855 | 37 #include "../Core/DicomFormat/DicomImageInformation.h" |
2487
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
38 #include "../Core/Images/Image.h" |
1612
96582230ddcb
Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
39 #include "../Core/Images/ImageProcessing.h" |
2487
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
40 #include "../Core/Images/ImageTraits.h" |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
41 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
42 #include <memory> |
853 | 43 |
44 using namespace Orthanc; | |
45 | |
46 | |
855 | 47 TEST(DicomImageInformation, ExtractPixelFormat1) |
853 | 48 { |
855 | 49 // Cardiac/MR* |
50 DicomMap m; | |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
51 m.SetValue(DICOM_TAG_ROWS, "24", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
52 m.SetValue(DICOM_TAG_COLUMNS, "16", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
53 m.SetValue(DICOM_TAG_BITS_ALLOCATED, "16", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
54 m.SetValue(DICOM_TAG_SAMPLES_PER_PIXEL, "1", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
55 m.SetValue(DICOM_TAG_BITS_STORED, "12", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
56 m.SetValue(DICOM_TAG_HIGH_BIT, "11", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
57 m.SetValue(DICOM_TAG_PIXEL_REPRESENTATION, "0", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
58 m.SetValue(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2", false); |
855 | 59 |
60 DicomImageInformation info(m); | |
61 PixelFormat format; | |
1905
8b1baa2315b8
Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
62 ASSERT_TRUE(info.ExtractPixelFormat(format, false)); |
855 | 63 ASSERT_EQ(PixelFormat_Grayscale16, format); |
853 | 64 } |
855 | 65 |
66 | |
67 TEST(DicomImageInformation, ExtractPixelFormat2) | |
68 { | |
69 // Delphine CT | |
70 DicomMap m; | |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
71 m.SetValue(DICOM_TAG_ROWS, "24", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
72 m.SetValue(DICOM_TAG_COLUMNS, "16", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
73 m.SetValue(DICOM_TAG_BITS_ALLOCATED, "16", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
74 m.SetValue(DICOM_TAG_SAMPLES_PER_PIXEL, "1", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
75 m.SetValue(DICOM_TAG_BITS_STORED, "16", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
76 m.SetValue(DICOM_TAG_HIGH_BIT, "15", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
77 m.SetValue(DICOM_TAG_PIXEL_REPRESENTATION, "1", false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
78 m.SetValue(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2", false); |
855 | 79 |
80 DicomImageInformation info(m); | |
81 PixelFormat format; | |
1905
8b1baa2315b8
Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
82 ASSERT_TRUE(info.ExtractPixelFormat(format, false)); |
855 | 83 ASSERT_EQ(PixelFormat_SignedGrayscale16, format); |
84 } | |
2487
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
85 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
86 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
87 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
88 namespace |
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 template <typename T> |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
91 class TestImageTraits : public ::testing::Test |
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 private: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
94 std::auto_ptr<Image> image_; |
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 protected: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
97 virtual void SetUp() |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
98 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
99 image_.reset(new Image(ImageTraits::PixelTraits::GetPixelFormat(), 7, 9, false)); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
100 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
101 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
102 virtual void TearDown() |
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 image_.reset(NULL); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
105 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
106 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
107 public: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
108 typedef T ImageTraits; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
109 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
110 ImageAccessor& GetImage() |
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 return *image_; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
113 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
114 }; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
115 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
116 template <typename T> |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
117 class TestIntegerImageTraits : public TestImageTraits<T> |
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 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
121 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
122 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
123 typedef ::testing::Types< |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
124 ImageTraits<PixelFormat_Grayscale8>, |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
125 ImageTraits<PixelFormat_Grayscale16>, |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
126 ImageTraits<PixelFormat_SignedGrayscale16> |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
127 > IntegerFormats; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
128 TYPED_TEST_CASE(TestIntegerImageTraits, IntegerFormats); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
129 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
130 typedef ::testing::Types< |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
131 ImageTraits<PixelFormat_Grayscale8>, |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
132 ImageTraits<PixelFormat_Grayscale16>, |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
133 ImageTraits<PixelFormat_SignedGrayscale16>, |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
134 ImageTraits<PixelFormat_RGB24>, |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
135 ImageTraits<PixelFormat_BGRA32> |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
136 > AllFormats; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
137 TYPED_TEST_CASE(TestImageTraits, AllFormats); |
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 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
140 TYPED_TEST(TestImageTraits, SetZero) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
141 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
142 ImageAccessor& image = this->GetImage(); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
143 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
144 memset(image.GetBuffer(), 128, image.GetHeight() * image.GetWidth()); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
145 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
146 switch (image.GetFormat()) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
147 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
148 case PixelFormat_Grayscale8: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
149 case PixelFormat_Grayscale16: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
150 case PixelFormat_SignedGrayscale16: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
151 ImageProcessing::Set(image, 0); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
152 break; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
153 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
154 case PixelFormat_RGB24: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
155 case PixelFormat_BGRA32: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
156 ImageProcessing::Set(image, 0, 0, 0, 0); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
157 break; |
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 default: |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
160 ASSERT_TRUE(0); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
161 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
162 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
163 typename TestFixture::ImageTraits::PixelType zero, value; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
164 TestFixture::ImageTraits::PixelTraits::SetZero(zero); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
165 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
166 for (unsigned int y = 0; y < image.GetHeight(); y++) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
167 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
168 for (unsigned int x = 0; x < image.GetWidth(); x++) |
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 TestFixture::ImageTraits::GetPixel(value, image, x, y); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
171 ASSERT_TRUE(TestFixture::ImageTraits::PixelTraits::IsEqual(zero, value)); |
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 } |
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 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
177 TYPED_TEST(TestIntegerImageTraits, SetZeroFloat) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
178 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
179 ImageAccessor& image = this->GetImage(); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
180 |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
181 memset(image.GetBuffer(), 128, image.GetHeight() * image.GetWidth()); |
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 unsigned int c = 0; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
184 for (unsigned int y = 0; y < image.GetHeight(); y++) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
185 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
186 for (unsigned int x = 0; x < image.GetWidth(); x++, c++) |
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 TestFixture::ImageTraits::SetFloatPixel(image, c, x, y); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
189 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
190 } |
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 c = 0; |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
193 for (unsigned int y = 0; y < image.GetHeight(); y++) |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
194 { |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
195 for (unsigned int x = 0; x < image.GetWidth(); x++, c++) |
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 ASSERT_FLOAT_EQ(c, TestFixture::ImageTraits::GetFloatPixel(image, x, y)); |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
198 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
199 } |
be1dbb1dcdd6
PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
200 } |