annotate UnitTestsSources/ImageProcessingTests.cpp @ 3751:89bd08fdd91b

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