0
我想減去兩個灰度圖像(CV_8UC1)並獲得它們的有符號差異作爲結果(CV_16SC1)。OpenCV圖像減法符號輸出
我已經嘗試了下面的代碼,但我得到差異CV_8UC1矩陣insted的簽署CV_16SC1。
你能否幫忙正確定義Mask矩陣和數據類型參數?
謝謝!
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
#include "Imagesubstraction.h"
using namespace cv;
using namespace std;
int main(void)
{
Mat M1, M2,Dif;
M1 = imread("../data/difference/a.bmp", CV_LOAD_IMAGE_GRAYSCALE);
M2 = imread("../data/difference/b.bmp", CV_LOAD_IMAGE_GRAYSCALE);
Mat Mask(1024, 1024, CV_8UC1, Scalar(1));
subtract(M1, M2, Dif,Mask,3);
imwrite("../data/difference/c.bmp", Dif);
return 0;
}