35 #include <visp3/core/vpImageTools.h>
42 #ifdef ENABLE_VISP_NAMESPACE
59 for (
unsigned int b = 0; b < n; b++) {
69 "Cannot compute image difference. The two images "
70 "(%ux%u) and (%ux%u) have not the same size",
78 for (
unsigned int b = 0; b < n; b++) {
93 unsigned int width = 501, height = 447;
94 vpImage<unsigned char> I1(height, width), I2(height, width), Idiff_regular(height, width), Idiff_sse(height, width);
95 vpImage<vpRGBa> I1_color(height, width), I2_color(height, width), Idiff_regular_color(height, width),
96 Idiff_sse_color(height, width);
97 for (
unsigned int i = 0; i < I1.
getRows(); i++) {
98 for (
unsigned int j = 0; j < I1.
getCols(); j++) {
99 I1[i][j] =
static_cast<unsigned char>(i * I1.
getCols() + j);
100 I1_color[i][j] =
vpRGBa(
static_cast<unsigned char>(i * I1.
getCols() + j));
105 std::cout <<
"Grayscale:" << std::endl;
107 double t_regular = 0.0, t_sse = 0.0;
108 for (
unsigned int cpt = 0; cpt < 256; cpt++) {
109 for (
unsigned int i = 0; i < I2.
getRows(); i++) {
110 for (
unsigned int j = 0; j < I2.
getCols(); j++) {
111 I2[i][j] =
static_cast<unsigned char>(i * I2.
getCols() + j + cpt);
116 regularImageDifference(I1, I2, Idiff_regular);
123 if (Idiff_regular != Idiff_sse) {
124 std::cerr <<
"Problem with vpImageTools::imageDifference()" << std::endl;
129 std::cout <<
"(Idiff_regular == Idiff_sse)" << std::endl;
130 std::cout <<
"t_regular: " << t_regular <<
" ms ; mean t_regular: " << t_regular / 256 <<
" ms" << std::endl;
131 std::cout <<
"t_sse: " << t_sse <<
" ms ; mean t_sse: " << t_sse / 256 <<
" ms" << std::endl;
132 std::cout <<
"speed-up: " << t_regular / t_sse <<
" times" << std::endl;
136 std::cout <<
"\nColor:" << std::endl;
138 double t_regular = 0.0, t_sse = 0.0;
139 for (
unsigned int cpt = 0; cpt < 256; cpt++) {
140 for (
unsigned int i = 0; i < I2.
getRows(); i++) {
141 for (
unsigned int j = 0; j < I2.
getCols(); j++) {
142 I2_color[i][j] =
vpRGBa(
static_cast<unsigned char>(i * I2.
getCols() + j + cpt));
147 regularImageDifference(I1_color, I2_color, Idiff_regular_color);
154 if (Idiff_regular_color != Idiff_sse_color) {
155 std::cerr <<
"Problem with vpImageTools::imageDifference()" << std::endl;
160 std::cout <<
"(Idiff_regular_color == Idiff_sse_color)" << std::endl;
161 std::cout <<
"t_regular: " << t_regular <<
" ms ; mean t_regular: " << t_regular / 256 <<
" ms" << std::endl;
162 std::cout <<
"t_sse: " << t_sse <<
" ms ; mean t_sse: " << t_sse / 256 <<
" ms" << std::endl;
163 std::cout <<
"speed-up: " << t_regular / t_sse <<
" times" << std::endl;
167 std::cout <<
"Test vpRGBa" << std::endl;
168 vpRGBa rgba_1(10, 20, 30);
169 vpRGBa rgba_2(10, 20, 30);
171 if (rgba_1 == rgba_2) {
172 std::cout <<
"Test ok: same rgba" << std::endl;
175 std::cerr <<
"Error in rgba operator==" << std::endl;
178 if (rgba_1 != rgba_2) {
179 std::cerr <<
"Error in rgba operator!=" << std::endl;
184 if (rgba_1 == (rgba_2 + rgba_3)) {
185 std::cerr <<
"Error in rgba operator==" << std::endl;
188 if (rgba_1 != (rgba_2 + rgba_3)) {
189 std::cerr <<
"Test ok: R value differ" << std::endl;
194 if (rgba_1 == (rgba_2 + rgba_3)) {
195 std::cerr <<
"Error in rgba operator==" << std::endl;
198 if (rgba_1 != (rgba_2 + rgba_3)) {
199 std::cerr <<
"Test ok: G value differ" << std::endl;
204 if (rgba_1 == (rgba_2 + rgba_3)) {
205 std::cerr <<
"Error in rgba operator==" << std::endl;
208 if (rgba_1 != (rgba_2 + rgba_3)) {
209 std::cerr <<
"Test ok: B value differ" << std::endl;
215 std::cout <<
"Test vpRGBf" << std::endl;
216 vpRGBf rgbf_1(10.f, 20.f, 30.f);
217 vpRGBf rgbf_2(10.f, 20.f, 30.f);
219 if (rgbf_1 == rgbf_2) {
220 std::cout <<
"Test ok: same rgbf" << std::endl;
223 std::cerr <<
"Error in rgbf operator==" << std::endl;
226 if (rgbf_1 != rgbf_2) {
227 std::cerr <<
"Error in rgbf operator!=" << std::endl;
231 vpRGBf rgbf_3(1e-6f, 0.f, 0.f);
232 if (rgbf_1 == (rgbf_2 + rgbf_3)) {
233 std::cerr <<
"Rf Error in rgbf operator==" << std::endl;
236 if (rgbf_1 != (rgbf_2 + rgbf_3)) {
237 std::cerr <<
"Test ok: Rf value differ" << std::endl;
241 vpRGBf rgbf_3(0.f, 1e-6f, 0.f);
242 if (rgbf_1 == (rgbf_2 + rgbf_3)) {
243 std::cerr <<
"Gf Error in rgbf operator==" << std::endl;
246 if (rgbf_1 != (rgbf_2 + rgbf_3)) {
247 std::cerr <<
"Test ok: Gf value differ" << std::endl;
251 vpRGBf rgbf_3(0.f, 0.f, 1e-6f);
252 if (rgbf_1 == (rgbf_2 + rgbf_3)) {
253 std::cerr <<
"Bf Error in rgbf operator==" << std::endl;
256 if (rgbf_1 != (rgbf_2 + rgbf_3)) {
257 std::cerr <<
"Test ok: Bf value differ" << std::endl;
262 std::cout <<
"Test succeed" << std::endl;
error that can be emitted by ViSP classes.
@ dimensionError
Bad dimension.
unsigned int getWidth() const
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
unsigned int getCols() const
Type * bitmap
points toward the bitmap
unsigned int getHeight() const
unsigned int getRows() const
static Type maximum(const Type &a, const Type &b)
static Type minimum(const Type &a, const Type &b)
unsigned char B
Blue component.
unsigned char R
Red component.
unsigned char G
Green component.
unsigned char A
Additionnal component.
VISP_EXPORT double measureTimeMs()