Changeset View
Changeset View
Standalone View
Standalone View
libs/image/tests/kis_mask_similarity_test.cpp
Context not available. | |||||
65 | QImage vectorImage(m_paintDev->convertToQImage(m_colorSpace->profile())); | 65 | QImage vectorImage(m_paintDev->convertToQImage(m_colorSpace->profile())); | ||
---|---|---|---|---|---|
66 | vectorImage.invertPixels(); // Make pixel color black | 66 | vectorImage.invertPixels(); // Make pixel color black | ||
67 | 67 | | |||
68 | if (renderImage) { | | |||
69 | scalarImage.save(QString(getTypeName(type) + "_scalar_mask.png"),"PNG"); | | |||
70 | vectorImage.save(QString(getTypeName(type) +"_vector_mask.png"),"PNG"); | | |||
71 | } | | |||
72 | | ||||
73 | // Check for differences, max errors: 0 | 68 | // Check for differences, max errors: 0 | ||
74 | QPoint tmpPt; | 69 | QPoint tmpPt; | ||
75 | QVERIFY(TestUtil::compareQImages(tmpPt,scalarImage, vectorImage, 0, 2, 0)); | 70 | QVERIFY(TestUtil::compareQImages(tmpPt,scalarImage, vectorImage, 0, 2, 0)); | ||
71 | | ||||
72 | if (renderImage || QTest::currentTestFailed()) { | ||||
73 | scalarImage.save(QString(getTypeName(type) + "_scalar_mask.png"),"PNG"); | ||||
74 | vectorImage.save(QString(getTypeName(type) + "_vector_mask.png"),"PNG"); | ||||
75 | } | ||||
76 | } | ||||
77 | | ||||
78 | | ||||
79 | static void exahustiveTest(QRect bounds, MaskType type) { | ||||
80 | // Exahustive test | ||||
81 | | ||||
82 | for (size_t i = 0; i <= 100; i += 5){ | ||||
83 | for (size_t j = 0; j <= 100; j += 5){ | ||||
84 | for (size_t k = 0; k <= 100; k += 20){ | ||||
85 | | ||||
86 | switch (type) { | ||||
87 | case CIRC_GAUSS: | ||||
88 | { | ||||
89 | KisGaussCircleMaskGenerator bCircVectr(499.5, k/100.f, i/100.f, j/100.f, 2, true); | ||||
90 | bCircVectr.setDiameter(499.5); | ||||
91 | KisGaussCircleMaskGenerator bCircScalar(bCircVectr); | ||||
92 | bCircScalar.resetMaskApplicator(true); // Force usage of scalar backend | ||||
93 | | ||||
94 | KisMaskSimilarityTester(bCircScalar.applicator(), bCircVectr.applicator(), bounds,type,false); | ||||
95 | break; | ||||
96 | } | ||||
97 | case CIRC_SOFT: | ||||
98 | { | ||||
99 | KisCubicCurve pointsCurve; | ||||
100 | pointsCurve.fromString(QString("0,1;1,0")); | ||||
101 | KisCurveCircleMaskGenerator bCircVectr(499.5, k/100.f, i/100.f, j/100.f, 2, pointsCurve, true); | ||||
102 | bCircVectr.setDiameter(499.5); | ||||
103 | KisCurveCircleMaskGenerator bCircScalar(bCircVectr); | ||||
104 | bCircScalar.resetMaskApplicator(true); // Force usage of scalar backend | ||||
105 | | ||||
106 | KisMaskSimilarityTester(bCircScalar.applicator(), bCircVectr.applicator(), bounds,type,false); | ||||
107 | break; | ||||
108 | } | ||||
109 | case RECT_GAUSS: | ||||
110 | { | ||||
111 | KisGaussRectangleMaskGenerator bCircVectr(499.5, k/100.f, i/100.f, j/100.f, 2, true); | ||||
112 | KisGaussRectangleMaskGenerator bCircScalar(bCircVectr); | ||||
113 | bCircScalar.resetMaskApplicator(true); // Force usage of scalar backend | ||||
114 | | ||||
115 | KisMaskSimilarityTester(bCircScalar.applicator(), bCircVectr.applicator(), bounds,type,false); | ||||
116 | break; | ||||
117 | | ||||
118 | } | ||||
119 | default: | ||||
120 | { | ||||
121 | return; | ||||
122 | break; | ||||
123 | } | ||||
124 | } | ||||
125 | | ||||
126 | } } } // end for | ||||
127 | return; | ||||
76 | } | 128 | } | ||
77 | 129 | | |||
78 | private: | 130 | private: | ||
Context not available. | |||||
115 | { | 167 | { | ||
116 | QRect bounds(0,0,500,500); | 168 | QRect bounds(0,0,500,500); | ||
117 | { | 169 | { | ||
118 | KisCircleMaskGenerator circVectr(500, 1.0, 0.5, 0.5, 2, true); | 170 | KisCircleMaskGenerator circVectr(499.5, 1.0, 0.5, 0.5, 2, true); | ||
119 | KisCircleMaskGenerator circScalar(circVectr); | 171 | KisCircleMaskGenerator circScalar(circVectr); | ||
120 | 172 | | |||
121 | circScalar.resetMaskApplicator(true); // Force usage of scalar backend | 173 | circScalar.resetMaskApplicator(true); // Force usage of scalar backend | ||
Context not available. | |||||
125 | 177 | | |||
126 | void KisMaskSimilarityTest::testGaussCircleMask() | 178 | void KisMaskSimilarityTest::testGaussCircleMask() | ||
127 | { | 179 | { | ||
128 | QRect bounds(0,0,500,500); | 180 | QRect bounds(0,0,520,520); | ||
129 | { | 181 | { | ||
130 | KisGaussCircleMaskGenerator circVectr(500, 1.0, .8, .2, 2, true); | 182 | KisGaussCircleMaskGenerator circVectr(499.5, 1.0, 1, 1, 2, true); | ||
131 | circVectr.setDiameter(500); | 183 | circVectr.setDiameter(499.5); | ||
132 | KisGaussCircleMaskGenerator circScalar(circVectr); | 184 | KisGaussCircleMaskGenerator circScalar(circVectr); | ||
133 | 185 | | |||
134 | circScalar.resetMaskApplicator(true); // Force usage of scalar backend | 186 | circScalar.resetMaskApplicator(true); // Force usage of scalar backend | ||
135 | KisMaskSimilarityTester(circScalar.applicator(), circVectr.applicator(), bounds, CIRC_GAUSS); | 187 | KisMaskSimilarityTester(circScalar.applicator(), circVectr.applicator(), bounds, CIRC_GAUSS); | ||
136 | } | 188 | } | ||
137 | // Exahustive test | 189 | | ||
138 | for (size_t i = 0; i <= 100; i += 3){ | 190 | KisMaskSimilarityTester::exahustiveTest(bounds,CIRC_GAUSS); | ||
139 | for (size_t j = 0; j <= 100; j += 3){ | | |||
140 | for (size_t k = 0; k <= 100; k += 15){ | | |||
141 | { | | |||
142 | KisGaussCircleMaskGenerator circVectr(500, k/100.f, i/100.f, j/100.f, 2, true); | | |||
143 | circVectr.setDiameter(500); | | |||
144 | KisGaussCircleMaskGenerator circScalar(circVectr); | | |||
145 | | ||||
146 | circScalar.resetMaskApplicator(true); // Force usage of scalar backend | | |||
147 | KisMaskSimilarityTester(circScalar.applicator(), circVectr.applicator(), bounds,CIRC_GAUSS,false); | | |||
148 | } | | |||
149 | } } } // end for | | |||
150 | } | 191 | } | ||
151 | 192 | | |||
152 | void KisMaskSimilarityTest::testSoftCircleMask() | 193 | void KisMaskSimilarityTest::testSoftCircleMask() | ||
153 | { | 194 | { | ||
154 | QRect bounds(0,0,500,500); | 195 | QRect bounds(0,0,520,520); | ||
155 | KisCubicCurve pointsCurve; | 196 | KisCubicCurve pointsCurve; | ||
156 | pointsCurve.fromString(QString("0,1;1,0")); | 197 | pointsCurve.fromString(QString("0,1;1,0")); | ||
157 | { | 198 | { | ||
158 | KisCurveCircleMaskGenerator circVectr(500, 1.0, 0.5, 0.5, 2, pointsCurve,true); | 199 | KisCurveCircleMaskGenerator circVectr(499.5, 1.0, 0.5, 0.5, 2, pointsCurve,true); | ||
159 | circVectr.setDiameter(500); | 200 | circVectr.setDiameter(500); | ||
160 | // circVectr.setSoftness(1.0); | 201 | // circVectr.setSoftness(1.0); | ||
161 | KisCurveCircleMaskGenerator circScalar(circVectr); | 202 | KisCurveCircleMaskGenerator circScalar(circVectr); | ||
Context not available. | |||||
164 | KisMaskSimilarityTester(circScalar.applicator(), circVectr.applicator(), bounds, CIRC_SOFT); | 205 | KisMaskSimilarityTester(circScalar.applicator(), circVectr.applicator(), bounds, CIRC_SOFT); | ||
165 | } | 206 | } | ||
166 | 207 | | |||
167 | // Exahustive test | 208 | KisMaskSimilarityTester::exahustiveTest(bounds,CIRC_SOFT); | ||
168 | for (size_t i = 0; i <= 100; i += 3){ | 209 | } | ||
169 | for (size_t j = 0; j <= 100; j += 3){ | 210 | | ||
170 | for (size_t k = 0; k <= 100; k += 15){ | 211 | void KisMaskSimilarityTest::testGaussRectMask() | ||
171 | { | 212 | { | ||
172 | KisCurveCircleMaskGenerator circVectr(500, k/100.f, i/100.f, j/100.f, 2,pointsCurve, true); | 213 | QRect bounds(0,0,540,540); | ||
173 | circVectr.setDiameter(500); | 214 | { | ||
174 | KisCurveCircleMaskGenerator circScalar(circVectr); | 215 | KisGaussRectangleMaskGenerator circVectr(499.5, 1.0, 0.5, 0.2, 2, true); | ||
175 | 216 | KisGaussRectangleMaskGenerator circScalar(circVectr); | |||
176 | circScalar.resetMaskApplicator(true); // Force usage of scalar backend | 217 | | ||
177 | KisMaskSimilarityTester(circScalar.applicator(), circVectr.applicator(), bounds,CIRC_SOFT,false); | 218 | circScalar.resetMaskApplicator(true); // Force usage of scalar backend | ||
178 | } | 219 | KisMaskSimilarityTester(circScalar.applicator(), circVectr.applicator(), bounds, RECT_GAUSS); | ||
179 | } } } // end for | 220 | } | ||
221 | | ||||
222 | KisMaskSimilarityTester::exahustiveTest(bounds,RECT_GAUSS); | ||||
180 | } | 223 | } | ||
181 | 224 | | |||
182 | QTEST_MAIN(KisMaskSimilarityTest) | 225 | QTEST_MAIN(KisMaskSimilarityTest) | ||
Context not available. |