annotate UnitTestsSources/ImageProcessingTests.cpp @ 3535:41365091a41e

display a security warning in the logs at startup when ExecuteLuaEnabled is true
author Alain Mazy <alain@mazy.be>
date Sun, 06 Oct 2019 09:52:57 +0200
parents 18566f9e1831
children 4066998150ef
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
3060
4e43e67f8ecf preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2924
diff changeset
5 * Copyright (C) 2017-2019 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
855
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
37 #include "../Core/DicomFormat/DicomImageInformation.h"
2487
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
38 #include "../Core/Images/Image.h"
1612
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
39 #include "../Core/Images/ImageProcessing.h"
2487
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
40 #include "../Core/Images/ImageTraits.h"
3366
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3365
diff changeset
41 #include "../Core/OrthancException.h"
2487
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
42
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
43 #include <memory>
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 using namespace Orthanc;
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
855
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
48 TEST(DicomImageInformation, ExtractPixelFormat1)
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 {
855
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
50 // Cardiac/MR*
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
51 DicomMap m;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1905
diff changeset
52 m.SetValue(DICOM_TAG_ROWS, "24", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1905
diff changeset
53 m.SetValue(DICOM_TAG_COLUMNS, "16", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1905
diff changeset
54 m.SetValue(DICOM_TAG_BITS_ALLOCATED, "16", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1905
diff changeset
55 m.SetValue(DICOM_TAG_SAMPLES_PER_PIXEL, "1", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1905
diff changeset
56 m.SetValue(DICOM_TAG_BITS_STORED, "12", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1905
diff changeset
57 m.SetValue(DICOM_TAG_HIGH_BIT, "11", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1905
diff changeset
58 m.SetValue(DICOM_TAG_PIXEL_REPRESENTATION, "0", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1905
diff changeset
59 m.SetValue(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2", false);
855
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
60
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
61 DicomImageInformation info(m);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
62 PixelFormat format;
1905
8b1baa2315b8 Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
63 ASSERT_TRUE(info.ExtractPixelFormat(format, false));
855
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
64 ASSERT_EQ(PixelFormat_Grayscale16, format);
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 }
855
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
66
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
67
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
68 TEST(DicomImageInformation, ExtractPixelFormat2)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
69 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
70 // Delphine CT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
71 DicomMap m;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1905
diff changeset
72 m.SetValue(DICOM_TAG_ROWS, "24", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1905
diff changeset
73 m.SetValue(DICOM_TAG_COLUMNS, "16", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1905
diff changeset
74 m.SetValue(DICOM_TAG_BITS_ALLOCATED, "16", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1905
diff changeset
75 m.SetValue(DICOM_TAG_SAMPLES_PER_PIXEL, "1", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1905
diff changeset
76 m.SetValue(DICOM_TAG_BITS_STORED, "16", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1905
diff changeset
77 m.SetValue(DICOM_TAG_HIGH_BIT, "15", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1905
diff changeset
78 m.SetValue(DICOM_TAG_PIXEL_REPRESENTATION, "1", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1905
diff changeset
79 m.SetValue(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2", false);
855
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
81 DicomImageInformation info(m);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
82 PixelFormat format;
1905
8b1baa2315b8 Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
83 ASSERT_TRUE(info.ExtractPixelFormat(format, false));
855
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
84 ASSERT_EQ(PixelFormat_SignedGrayscale16, format);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
85 }
2487
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
86
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
87
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
88
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
89 namespace
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
90 {
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
91 template <typename T>
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
92 class TestImageTraits : public ::testing::Test
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
93 {
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
94 private:
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
95 std::auto_ptr<Image> image_;
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
96
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
97 protected:
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2487
diff changeset
98 virtual void SetUp() ORTHANC_OVERRIDE
2487
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
99 {
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
100 image_.reset(new Image(ImageTraits::PixelTraits::GetPixelFormat(), 7, 9, false));
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
101 }
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
102
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2487
diff changeset
103 virtual void TearDown() ORTHANC_OVERRIDE
2487
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
104 {
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
105 image_.reset(NULL);
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
106 }
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
107
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
108 public:
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
109 typedef T ImageTraits;
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
110
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
111 ImageAccessor& GetImage()
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
112 {
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
113 return *image_;
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
114 }
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
115 };
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
116
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
117 template <typename T>
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
118 class TestIntegerImageTraits : public TestImageTraits<T>
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
119 {
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
120 };
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
121 }
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
122
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
123
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
124 typedef ::testing::Types<
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
125 ImageTraits<PixelFormat_Grayscale8>,
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
126 ImageTraits<PixelFormat_Grayscale16>,
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
127 ImageTraits<PixelFormat_SignedGrayscale16>
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
128 > IntegerFormats;
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
129 TYPED_TEST_CASE(TestIntegerImageTraits, IntegerFormats);
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
130
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
131 typedef ::testing::Types<
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
132 ImageTraits<PixelFormat_Grayscale8>,
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
133 ImageTraits<PixelFormat_Grayscale16>,
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
134 ImageTraits<PixelFormat_SignedGrayscale16>,
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
135 ImageTraits<PixelFormat_RGB24>,
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
136 ImageTraits<PixelFormat_BGRA32>
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
137 > AllFormats;
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
138 TYPED_TEST_CASE(TestImageTraits, AllFormats);
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
139
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
140
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
141 TYPED_TEST(TestImageTraits, SetZero)
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
142 {
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
143 ImageAccessor& image = this->GetImage();
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
144
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
145 memset(image.GetBuffer(), 128, image.GetHeight() * image.GetWidth());
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
146
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
147 switch (image.GetFormat())
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
148 {
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
149 case PixelFormat_Grayscale8:
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
150 case PixelFormat_Grayscale16:
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
151 case PixelFormat_SignedGrayscale16:
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
152 ImageProcessing::Set(image, 0);
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
153 break;
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
154
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
155 case PixelFormat_RGB24:
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
156 case PixelFormat_BGRA32:
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
157 ImageProcessing::Set(image, 0, 0, 0, 0);
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
158 break;
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
159
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
160 default:
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
161 ASSERT_TRUE(0);
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
162 }
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
163
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
164 typename TestFixture::ImageTraits::PixelType zero, value;
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
165 TestFixture::ImageTraits::PixelTraits::SetZero(zero);
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
166
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
167 for (unsigned int y = 0; y < image.GetHeight(); y++)
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
168 {
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
169 for (unsigned int x = 0; x < image.GetWidth(); x++)
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
170 {
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
171 TestFixture::ImageTraits::GetPixel(value, image, x, y);
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
172 ASSERT_TRUE(TestFixture::ImageTraits::PixelTraits::IsEqual(zero, value));
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
173 }
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
174 }
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
175 }
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
176
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
177
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
178 TYPED_TEST(TestIntegerImageTraits, SetZeroFloat)
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
179 {
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
180 ImageAccessor& image = this->GetImage();
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
181
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
182 memset(image.GetBuffer(), 128, image.GetHeight() * image.GetWidth());
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
183
3258
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
184 float c = 0.0f;
2487
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
185 for (unsigned int y = 0; y < image.GetHeight(); y++)
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
186 {
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
187 for (unsigned int x = 0; x < image.GetWidth(); x++, c++)
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
188 {
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
189 TestFixture::ImageTraits::SetFloatPixel(image, c, x, y);
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
190 }
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
191 }
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
192
3260
345f86fd1ac3 fix (shame on me for not testing)
Alain Mazy <alain@mazy.be>
parents: 3258
diff changeset
193 c = 0.0f;
2487
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
194 for (unsigned int y = 0; y < image.GetHeight(); y++)
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
195 {
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
196 for (unsigned int x = 0; x < image.GetWidth(); x++, c++)
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
197 {
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
198 ASSERT_FLOAT_EQ(c, TestFixture::ImageTraits::GetFloatPixel(image, x, y));
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
199 }
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
200 }
be1dbb1dcdd6 PixelTraits and ImageTraits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
201 }
3258
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
202
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
203 TYPED_TEST(TestIntegerImageTraits, FillPolygon)
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
204 {
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
205 ImageAccessor& image = this->GetImage();
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
206
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
207 ImageProcessing::Set(image, 128);
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
208
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
209 // draw a triangle
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
210 std::vector<ImageProcessing::ImagePoint> points;
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
211 points.push_back(ImageProcessing::ImagePoint(1,1));
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
212 points.push_back(ImageProcessing::ImagePoint(1,5));
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
213 points.push_back(ImageProcessing::ImagePoint(5,5));
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
214
3503
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
215 ImageProcessing::FillPolygon(image, points, 255);
3258
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
216
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
217 // outside polygon
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
218 ASSERT_FLOAT_EQ(128, TestFixture::ImageTraits::GetFloatPixel(image, 0, 0));
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
219 ASSERT_FLOAT_EQ(128, TestFixture::ImageTraits::GetFloatPixel(image, 0, 6));
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
220 ASSERT_FLOAT_EQ(128, TestFixture::ImageTraits::GetFloatPixel(image, 6, 6));
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
221 ASSERT_FLOAT_EQ(128, TestFixture::ImageTraits::GetFloatPixel(image, 6, 0));
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
222
3431
e0841192d7d0 improved FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3366
diff changeset
223 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 1, 1));
3258
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
224 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 1, 2));
3431
e0841192d7d0 improved FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3366
diff changeset
225 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 1, 5));
3258
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
226 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 2, 4));
3431
e0841192d7d0 improved FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3366
diff changeset
227 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 5, 5));
3258
6f652c7bfc85 ImageProcessing::FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
228 }
3365
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
229
3366
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3365
diff changeset
230 TYPED_TEST(TestIntegerImageTraits, FillPolygonLargerThanImage)
3365
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
231 {
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
232 ImageAccessor& image = this->GetImage();
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
233
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
234 ImageProcessing::Set(image, 0);
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
235
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
236 std::vector<ImageProcessing::ImagePoint> points;
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
237 points.push_back(ImageProcessing::ImagePoint(0, 0));
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
238 points.push_back(ImageProcessing::ImagePoint(image.GetWidth(),0));
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
239 points.push_back(ImageProcessing::ImagePoint(image.GetWidth(),image.GetHeight()));
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
240 points.push_back(ImageProcessing::ImagePoint(0,image.GetHeight()));
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
241
3503
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
242 ASSERT_THROW(ImageProcessing::FillPolygon(image, points, 255), OrthancException);
3365
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
243 }
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 TYPED_TEST(TestIntegerImageTraits, FillPolygonFullImage)
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
246 {
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
247 ImageAccessor& image = this->GetImage();
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
248
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
249 ImageProcessing::Set(image, 0);
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
250
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
251 std::vector<ImageProcessing::ImagePoint> points;
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
252 points.push_back(ImageProcessing::ImagePoint(0, 0));
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
253 points.push_back(ImageProcessing::ImagePoint(image.GetWidth() - 1,0));
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
254 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
255 points.push_back(ImageProcessing::ImagePoint(0,image.GetHeight() - 1));
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
256
3503
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
257 ImageProcessing::FillPolygon(image, points, 255);
3365
9345710bbf12 check limits in fillpolygon
Alain Mazy <alain@mazy.be>
parents: 3260
diff changeset
258
3431
e0841192d7d0 improved FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3366
diff changeset
259 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 0, 0));
e0841192d7d0 improved FillPolygon
Alain Mazy <alain@mazy.be>
parents: 3366
diff changeset
260 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
261 }
3503
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
262
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 static void SetGrayscale8Pixel(ImageAccessor& image,
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
267 unsigned int x,
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
268 unsigned int y,
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
269 uint8_t value)
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
270 {
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
271 ImageTraits<PixelFormat_Grayscale8>::SetPixel(image, value, x, y);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
272 }
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
273
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
274 static bool TestGrayscale8Pixel(const ImageAccessor& image,
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
275 unsigned int x,
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
276 unsigned int y,
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
277 uint8_t value)
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
278 {
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
279 PixelTraits<PixelFormat_Grayscale8>::PixelType p;
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
280 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
281 if (p != value) printf("%d %d\n", p, value);
3503
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
282 return p == value;
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
283 }
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
284
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
285 static void SetRGB24Pixel(ImageAccessor& image,
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
286 unsigned int x,
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
287 unsigned int y,
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
288 uint8_t red,
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
289 uint8_t green,
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
290 uint8_t blue)
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
291 {
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
292 PixelTraits<PixelFormat_RGB24>::PixelType p;
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
293 p.red_ = red;
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
294 p.green_ = green;
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
295 p.blue_ = blue;
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
296 ImageTraits<PixelFormat_RGB24>::SetPixel(image, p, x, y);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
297 }
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
298
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
299 static bool TestRGB24Pixel(const ImageAccessor& image,
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
300 unsigned int x,
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
301 unsigned int y,
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
302 uint8_t red,
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
303 uint8_t green,
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
304 uint8_t blue)
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
305 {
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
306 PixelTraits<PixelFormat_RGB24>::PixelType p;
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
307 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
308 bool ok = (p.red_ == red &&
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
309 p.green_ == green &&
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
310 p.blue_ == blue);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
311 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
312 return ok;
3503
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
313 }
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
314
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
315
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
316 TEST(ImageProcessing, FlipGrayscale8)
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
317 {
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
318 {
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
319 Image image(PixelFormat_Grayscale8, 0, 0, false);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
320 ImageProcessing::FlipX(image);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
321 ImageProcessing::FlipY(image);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
322 }
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
323
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
324 {
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
325 Image image(PixelFormat_Grayscale8, 1, 1, false);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
326 SetGrayscale8Pixel(image, 0, 0, 128);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
327 ImageProcessing::FlipX(image);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
328 ImageProcessing::FlipY(image);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
329 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 0, 128));
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
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
332 {
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
333 Image image(PixelFormat_Grayscale8, 3, 2, false);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
334 SetGrayscale8Pixel(image, 0, 0, 10);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
335 SetGrayscale8Pixel(image, 1, 0, 20);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
336 SetGrayscale8Pixel(image, 2, 0, 30);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
337 SetGrayscale8Pixel(image, 0, 1, 40);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
338 SetGrayscale8Pixel(image, 1, 1, 50);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
339 SetGrayscale8Pixel(image, 2, 1, 60);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
340
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
341 ImageProcessing::FlipX(image);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
342 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 0, 30));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
343 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 0, 20));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
344 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 0, 10));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
345 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 1, 60));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
346 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 1, 50));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
347 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 1, 40));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
348
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
349 ImageProcessing::FlipY(image);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
350 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 0, 60));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
351 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 0, 50));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
352 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 0, 40));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
353 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 1, 30));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
354 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 1, 20));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
355 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 1, 10));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
356 }
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
357 }
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
358
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
359
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
360
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
361 TEST(ImageProcessing, FlipRGB24)
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 Image image(PixelFormat_RGB24, 2, 2, false);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
364 SetRGB24Pixel(image, 0, 0, 10, 100, 110);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
365 SetRGB24Pixel(image, 1, 0, 20, 100, 110);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
366 SetRGB24Pixel(image, 0, 1, 30, 100, 110);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
367 SetRGB24Pixel(image, 1, 1, 40, 100, 110);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
368
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
369 ImageProcessing::FlipX(image);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
370 ASSERT_TRUE(TestRGB24Pixel(image, 0, 0, 20, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
371 ASSERT_TRUE(TestRGB24Pixel(image, 1, 0, 10, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
372 ASSERT_TRUE(TestRGB24Pixel(image, 0, 1, 40, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
373 ASSERT_TRUE(TestRGB24Pixel(image, 1, 1, 30, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
374
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
375 ImageProcessing::FlipY(image);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
376 ASSERT_TRUE(TestRGB24Pixel(image, 0, 0, 40, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
377 ASSERT_TRUE(TestRGB24Pixel(image, 1, 0, 30, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
378 ASSERT_TRUE(TestRGB24Pixel(image, 0, 1, 20, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
379 ASSERT_TRUE(TestRGB24Pixel(image, 1, 1, 10, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
380 }
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
381
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
382
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
383 TEST(ImageProcessing, ResizeBasicGrayscale8)
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
384 {
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
385 Image source(PixelFormat_Grayscale8, 2, 2, false);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
386 SetGrayscale8Pixel(source, 0, 0, 10);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
387 SetGrayscale8Pixel(source, 1, 0, 20);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
388 SetGrayscale8Pixel(source, 0, 1, 30);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
389 SetGrayscale8Pixel(source, 1, 1, 40);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
390
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
391 {
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
392 Image target(PixelFormat_Grayscale8, 2, 4, false);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
393 ImageProcessing::Resize(target, source);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
394 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 0, 10));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
395 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 0, 20));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
396 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 1, 10));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
397 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 1, 20));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
398 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 2, 30));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
399 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 2, 40));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
400 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 3, 30));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
401 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 3, 40));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
402 }
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
403
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
404 {
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
405 Image target(PixelFormat_Grayscale8, 4, 2, false);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
406 ImageProcessing::Resize(target, source);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
407 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 0, 10));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
408 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 0, 10));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
409 ASSERT_TRUE(TestGrayscale8Pixel(target, 2, 0, 20));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
410 ASSERT_TRUE(TestGrayscale8Pixel(target, 3, 0, 20));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
411 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 1, 30));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
412 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 1, 30));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
413 ASSERT_TRUE(TestGrayscale8Pixel(target, 2, 1, 40));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
414 ASSERT_TRUE(TestGrayscale8Pixel(target, 3, 1, 40));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
415 }
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
416 }
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
417
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
418
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
419 TEST(ImageProcessing, ResizeBasicRGB24)
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 Image source(PixelFormat_RGB24, 2, 2, false);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
422 SetRGB24Pixel(source, 0, 0, 10, 100, 110);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
423 SetRGB24Pixel(source, 1, 0, 20, 100, 110);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
424 SetRGB24Pixel(source, 0, 1, 30, 100, 110);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
425 SetRGB24Pixel(source, 1, 1, 40, 100, 110);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
426
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
427 {
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
428 Image target(PixelFormat_RGB24, 2, 4, false);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
429 ImageProcessing::Resize(target, source);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
430 ASSERT_TRUE(TestRGB24Pixel(target, 0, 0, 10, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
431 ASSERT_TRUE(TestRGB24Pixel(target, 1, 0, 20, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
432 ASSERT_TRUE(TestRGB24Pixel(target, 0, 1, 10, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
433 ASSERT_TRUE(TestRGB24Pixel(target, 1, 1, 20, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
434 ASSERT_TRUE(TestRGB24Pixel(target, 0, 2, 30, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
435 ASSERT_TRUE(TestRGB24Pixel(target, 1, 2, 40, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
436 ASSERT_TRUE(TestRGB24Pixel(target, 0, 3, 30, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
437 ASSERT_TRUE(TestRGB24Pixel(target, 1, 3, 40, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
438 }
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
439
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
440 {
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
441 Image target(PixelFormat_RGB24, 4, 2, false);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
442 ImageProcessing::Resize(target, source);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
443 ASSERT_TRUE(TestRGB24Pixel(target, 0, 0, 10, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
444 ASSERT_TRUE(TestRGB24Pixel(target, 1, 0, 10, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
445 ASSERT_TRUE(TestRGB24Pixel(target, 2, 0, 20, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
446 ASSERT_TRUE(TestRGB24Pixel(target, 3, 0, 20, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
447 ASSERT_TRUE(TestRGB24Pixel(target, 0, 1, 30, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
448 ASSERT_TRUE(TestRGB24Pixel(target, 1, 1, 30, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
449 ASSERT_TRUE(TestRGB24Pixel(target, 2, 1, 40, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
450 ASSERT_TRUE(TestRGB24Pixel(target, 3, 1, 40, 100, 110));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
451 }
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
452 }
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
453
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 TEST(ImageProcessing, ResizeEmptyGrayscale8)
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 Image source(PixelFormat_Grayscale8, 0, 0, false);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
459 Image target(PixelFormat_Grayscale8, 2, 2, false);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
460 ImageProcessing::Resize(target, source);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
461 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 0, 0));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
462 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 0, 0));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
463 ASSERT_TRUE(TestGrayscale8Pixel(target, 0, 1, 0));
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
464 ASSERT_TRUE(TestGrayscale8Pixel(target, 1, 1, 0));
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 {
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
468 Image source(PixelFormat_Grayscale8, 2, 2, false);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
469 Image target(PixelFormat_Grayscale8, 0, 0, false);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
470 ImageProcessing::Resize(target, source);
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
471 }
46cf170ba121 ImageProcessing::SeparableConvolution()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3431
diff changeset
472 }
3504
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
473
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
474
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
475 TEST(ImageProcessing, Convolution)
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
476 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
477 std::vector<float> k1(5, 1);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
478 std::vector<float> k2(1, 1);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
479
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
480 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
481 Image image(PixelFormat_Grayscale8, 1, 1, false);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
482 SetGrayscale8Pixel(image, 0, 0, 100);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
483 ImageProcessing::SeparableConvolution(image, k1, 2, k2, 0);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
484 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 0, 100));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
485 ImageProcessing::SeparableConvolution(image, k1, 2, k1, 2);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
486 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 0, 100));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
487 ImageProcessing::SeparableConvolution(image, k2, 0, k1, 2);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
488 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 0, 100));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
489 ImageProcessing::SeparableConvolution(image, k2, 0, k2, 0);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
490 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 0, 100));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
491 }
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
492
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
493 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
494 Image image(PixelFormat_RGB24, 1, 1, false);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
495 SetRGB24Pixel(image, 0, 0, 10, 20, 30);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
496 ImageProcessing::SeparableConvolution(image, k1, 2, k2, 0);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
497 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
498 ImageProcessing::SeparableConvolution(image, k1, 2, k1, 2);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
499 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
500 ImageProcessing::SeparableConvolution(image, k2, 0, k1, 2);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
501 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
502 ImageProcessing::SeparableConvolution(image, k2, 0, k2, 0);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
503 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
504 }
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
505
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
506 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
507 Image dirac(PixelFormat_Grayscale8, 9, 1, false);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
508 ImageProcessing::Set(dirac, 0);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
509 SetGrayscale8Pixel(dirac, 4, 0, 100);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
510
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
511 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
512 std::auto_ptr<ImageAccessor> image(Image::Clone(dirac));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
513 ImageProcessing::SeparableConvolution(*image, k1, 2, k2, 0);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
514 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
515 ASSERT_TRUE(TestGrayscale8Pixel(*image, 1, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
516 ASSERT_TRUE(TestGrayscale8Pixel(*image, 2, 0, 20));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
517 ASSERT_TRUE(TestGrayscale8Pixel(*image, 3, 0, 20));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
518 ASSERT_TRUE(TestGrayscale8Pixel(*image, 4, 0, 20));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
519 ASSERT_TRUE(TestGrayscale8Pixel(*image, 5, 0, 20));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
520 ASSERT_TRUE(TestGrayscale8Pixel(*image, 6, 0, 20));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
521 ASSERT_TRUE(TestGrayscale8Pixel(*image, 7, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
522 ASSERT_TRUE(TestGrayscale8Pixel(*image, 8, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
523 }
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
524
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
525 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
526 std::auto_ptr<ImageAccessor> image(Image::Clone(dirac));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
527 ImageProcessing::SeparableConvolution(*image, k2, 0, k1, 2);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
528 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
529 ASSERT_TRUE(TestGrayscale8Pixel(*image, 1, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
530 ASSERT_TRUE(TestGrayscale8Pixel(*image, 2, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
531 ASSERT_TRUE(TestGrayscale8Pixel(*image, 3, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
532 ASSERT_TRUE(TestGrayscale8Pixel(*image, 4, 0, 100));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
533 ASSERT_TRUE(TestGrayscale8Pixel(*image, 5, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
534 ASSERT_TRUE(TestGrayscale8Pixel(*image, 6, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
535 ASSERT_TRUE(TestGrayscale8Pixel(*image, 7, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
536 ASSERT_TRUE(TestGrayscale8Pixel(*image, 8, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
537 }
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
538
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
539 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
540 std::auto_ptr<ImageAccessor> image(Image::Clone(dirac));
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(TestGrayscale8Pixel(*image, 0, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
543 ASSERT_TRUE(TestGrayscale8Pixel(*image, 1, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
544 ASSERT_TRUE(TestGrayscale8Pixel(*image, 2, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
545 ASSERT_TRUE(TestGrayscale8Pixel(*image, 3, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
546 ASSERT_TRUE(TestGrayscale8Pixel(*image, 4, 0, 100));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
547 ASSERT_TRUE(TestGrayscale8Pixel(*image, 5, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
548 ASSERT_TRUE(TestGrayscale8Pixel(*image, 6, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
549 ASSERT_TRUE(TestGrayscale8Pixel(*image, 7, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
550 ASSERT_TRUE(TestGrayscale8Pixel(*image, 8, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
551 }
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
552 }
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
553
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
554 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
555 Image dirac(PixelFormat_Grayscale8, 1, 9, false);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
556 ImageProcessing::Set(dirac, 0);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
557 SetGrayscale8Pixel(dirac, 0, 4, 100);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
558
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
559 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
560 std::auto_ptr<ImageAccessor> image(Image::Clone(dirac));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
561 ImageProcessing::SeparableConvolution(*image, k2, 0, k1, 2);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
562 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
563 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 1, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
564 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 2, 20));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
565 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 3, 20));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
566 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 4, 20));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
567 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 5, 20));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
568 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 6, 20));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
569 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 7, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
570 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 8, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
571 }
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
572
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
573 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
574 std::auto_ptr<ImageAccessor> image(Image::Clone(dirac));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
575 ImageProcessing::SeparableConvolution(*image, k1, 2, k2, 0);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
576 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
577 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 1, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
578 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 2, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
579 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 3, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
580 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 4, 100));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
581 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 5, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
582 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 6, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
583 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 7, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
584 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 8, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
585 }
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
586
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
587 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
588 std::auto_ptr<ImageAccessor> image(Image::Clone(dirac));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
589 ImageProcessing::SeparableConvolution(*image, k2, 0, k2, 0);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
590 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
591 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 1, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
592 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 2, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
593 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 3, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
594 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 4, 100));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
595 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 5, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
596 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 6, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
597 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 7, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
598 ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 8, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
599 }
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
600 }
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
601
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
602 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
603 Image dirac(PixelFormat_RGB24, 9, 1, false);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
604 ImageProcessing::Set(dirac, 0);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
605 SetRGB24Pixel(dirac, 4, 0, 100, 120, 140);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
606
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
607 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
608 std::auto_ptr<ImageAccessor> image(Image::Clone(dirac));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
609 ImageProcessing::SeparableConvolution(*image, k1, 2, k2, 0);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
610 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
611 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
612 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
613 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
614 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
615 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
616 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
617 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
618 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
619 }
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
620
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
621 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
622 std::auto_ptr<ImageAccessor> image(Image::Clone(dirac));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
623 ImageProcessing::SeparableConvolution(*image, k2, 0, k1, 2);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
624 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
625 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
626 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
627 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
628 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
629 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
630 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
631 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
632 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
633 }
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
634
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
635 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
636 std::auto_ptr<ImageAccessor> image(Image::Clone(dirac));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
637 ImageProcessing::SeparableConvolution(*image, k2, 0, k2, 0);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
638 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
639 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
640 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
641 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
642 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
643 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
644 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
645 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
646 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
647 }
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
648 }
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
649
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
650 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
651 Image dirac(PixelFormat_RGB24, 1, 9, false);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
652 ImageProcessing::Set(dirac, 0);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
653 SetRGB24Pixel(dirac, 0, 4, 100, 120, 140);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
654
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
655 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
656 std::auto_ptr<ImageAccessor> image(Image::Clone(dirac));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
657 ImageProcessing::SeparableConvolution(*image, k2, 0, k1, 2);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
658 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
659 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
660 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
661 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
662 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
663 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
664 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
665 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
666 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
667 }
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
668
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
669 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
670 std::auto_ptr<ImageAccessor> image(Image::Clone(dirac));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
671 ImageProcessing::SeparableConvolution(*image, k1, 2, k2, 0);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
672 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
673 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
674 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
675 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
676 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
677 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
678 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
679 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
680 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
681 }
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
682
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
683 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
684 std::auto_ptr<ImageAccessor> image(Image::Clone(dirac));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
685 ImageProcessing::SeparableConvolution(*image, k2, 0, k2, 0);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
686 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
687 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
688 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
689 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
690 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
691 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
692 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
693 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
694 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
695 }
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
696 }
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
697 }
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
698
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
699
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
700 TEST(ImageProcessing, SmoothGaussian5x5)
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
701 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
702 /**
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
703 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
704 g1 = [ 1 4 6 4 1 ];
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
705 g1 /= sum(g1);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
706 g2 = conv2(g1, g1');
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
707 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
708 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
709 **/
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
710
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
711 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
712 Image image(PixelFormat_Grayscale8, 5, 5, false);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
713 ImageProcessing::Set(image, 0);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
714 SetGrayscale8Pixel(image, 2, 2, 100);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
715 ImageProcessing::SmoothGaussian5x5(image);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
716
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
717 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
718 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 0, 1));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
719 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 0, 2));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
720 ASSERT_TRUE(TestGrayscale8Pixel(image, 3, 0, 1));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
721 ASSERT_TRUE(TestGrayscale8Pixel(image, 4, 0, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
722 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 1, 1));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
723 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 1, 6));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
724 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 1, 9));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
725 ASSERT_TRUE(TestGrayscale8Pixel(image, 3, 1, 6));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
726 ASSERT_TRUE(TestGrayscale8Pixel(image, 4, 1, 1));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
727 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 2, 2));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
728 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 2, 9));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
729 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 2, 14));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
730 ASSERT_TRUE(TestGrayscale8Pixel(image, 3, 2, 9));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
731 ASSERT_TRUE(TestGrayscale8Pixel(image, 4, 2, 2));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
732 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 3, 1));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
733 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 3, 6));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
734 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 3, 9));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
735 ASSERT_TRUE(TestGrayscale8Pixel(image, 3, 3, 6));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
736 ASSERT_TRUE(TestGrayscale8Pixel(image, 4, 3, 1));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
737 ASSERT_TRUE(TestGrayscale8Pixel(image, 0, 4, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
738 ASSERT_TRUE(TestGrayscale8Pixel(image, 1, 4, 1));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
739 ASSERT_TRUE(TestGrayscale8Pixel(image, 2, 4, 2));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
740 ASSERT_TRUE(TestGrayscale8Pixel(image, 3, 4, 1));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
741 ASSERT_TRUE(TestGrayscale8Pixel(image, 4, 4, 0));
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
742 }
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
743
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
744 {
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
745 Image image(PixelFormat_RGB24, 5, 5, false);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
746 ImageProcessing::Set(image, 0);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
747 SetRGB24Pixel(image, 2, 2, 100, 100, 200);
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
748 ImageProcessing::SmoothGaussian5x5(image);
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 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
751 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
752 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
753 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
754 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
755 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
756 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
757 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
758 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
759 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
760 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
761 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
762 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
763 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
764 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
765 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
766 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
767 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
768 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
769 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
770 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
771 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
772 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
773 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
774 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
775 }
18566f9e1831 unit testing new functions in ImageProcessing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3503
diff changeset
776 }