sub_scalar_to_mat.cpp

Application testing the issue of the ticket - Luis Díaz Más, 2012-01-11 11:22 pm

Download (794 Bytes)

 
1
/*!
2
 *      @file  sub_scalar_to_mat.cpp
3
 *     @brief  Adding/subtracting a scalar to Mat results in garbled output
4
 *             in 64bit. Ticket 1460.
5
 *
6
 *    @author  Luis Diaz Mas (LDM), [email protected]
7
 *
8
 *  @internal
9
 *    Created  11/01/12
10
 *   Revision 01/11/12 - 23:15:30
11
 *   Compiler  gcc/g++
12
 *
13
 * This source code is released for free distribution under the terms of the
14
 * GNU General Public License as published by the Free Software Foundation.
15
 */
16
17
#include <opencv2/highgui/highgui.hpp>
18
19
using cv::Mat;
20
using cv::imwrite;
21
using cv::Scalar;
22
23
int main()
24
{
25
  Mat image(256, 256, CV_8UC1, Scalar(125));
26
  image.setTo(128);
27
  Mat result = image - 64;
28
  imwrite("subtract_test.png", result);
29
30
  subtract(image, Scalar(255), result);
31
  imwrite("subtract_test2.png", result);
32
}