Ask Your Question

Revision history [back]

subtract method replace negative values with zeros

I am doing subtraction of grayscale images. i want to keep negative values. but subtract method in opencv replace negative values with zeros. User Mat types are CV_32S, CV_32F.image description

click to hide/show revision 2
retagged

updated 2018-07-03 06:36:30 -0600

berak gravatar image

subtract method replace negative values with zeros

I am doing subtraction of grayscale images. i want to keep negative values. but subtract method in opencv replace negative values with zeros. User Mat types are CV_32S, CV_32F.image description

subtract method replace negative values with zeros

I am doing subtraction of grayscale images. i want to keep negative values. but subtract method in opencv replace negative values with zeros. User Mat types are CV_32S, CV_32F.image description
public double corr2(Mat img1, Mat img2){
Mat grayImg1,grayImg2;
grayImg1=new Mat(300,300,CV_32S);
grayImg2=new Mat(300,300,CV_32S);
Imgproc.cvtColor(img1,grayImg1,COLOR_RGB2GRAY);
Imgproc.cvtColor(img2,grayImg2,COLOR_RGB2GRAY);
Scalar img1mean=Core.mean(grayImg1);
Scalar img2mean=Core.mean(grayImg2);
Core.subtract(grayImg1,img1mean,grayImg1);

click to hide/show revision 4
None

updated 2018-07-03 07:26:03 -0600

berak gravatar image

subtract method replace negative values with zeros

I am doing subtraction of grayscale images. i want to keep negative values. but subtract method in opencv replace negative values with zeros. User Mat types are CV_32S, CV_32F.

public double corr2(Mat img1, Mat img2){
img2){ Mat grayImg1,grayImg2;
grayImg1,grayImg2;<br> grayImg1=new Mat(300,300,CV_32S);
Mat(300,300,CV_32S);<br> grayImg2=new Mat(300,300,CV_32S);
Mat(300,300,CV_32S);<br> Imgproc.cvtColor(img1,grayImg1,COLOR_RGB2GRAY);
Imgproc.cvtColor(img1,grayImg1,COLOR_RGB2GRAY);<br> Imgproc.cvtColor(img2,grayImg2,COLOR_RGB2GRAY);
Imgproc.cvtColor(img2,grayImg2,COLOR_RGB2GRAY);<br> Scalar img1mean=Core.mean(grayImg1);
<br> Scalar img2mean=Core.mean(grayImg2);
img2mean=Core.mean(grayImg2);<br> Core.subtract(grayImg1,img1mean,grayImg1);

Core.subtract(grayImg1,img1mean,grayImg1);
click to hide/show revision 5
None

updated 2018-07-03 07:26:56 -0600

berak gravatar image

subtract method replace negative values with zeros

I am doing subtraction of grayscale images. i want to keep negative values. but subtract method in opencv replace negative values with zeros. User Mat types are CV_32S, CV_32F.

public double corr2(Mat img1, Mat img2){

        Mat grayImg1,grayImg2;<br>
grayImg1,grayImg2;
        grayImg1=new Mat(300,300,CV_32S);<br>
Mat(300,300,CV_32S);
        grayImg2=new Mat(300,300,CV_32S);<br>
Mat(300,300,CV_32S);
 Imgproc.cvtColor(img1,grayImg1,COLOR_RGB2GRAY);<br>
Imgproc.cvtColor(img1,grayImg1,COLOR_RGB2GRAY);
 Imgproc.cvtColor(img2,grayImg2,COLOR_RGB2GRAY);<br>
Imgproc.cvtColor(img2,grayImg2,COLOR_RGB2GRAY);
        Scalar img1mean=Core.mean(grayImg1); <br>
img1mean=Core.mean(grayImg1);
        Scalar img2mean=Core.mean(grayImg2);<br>
img2mean=Core.mean(grayImg2);
        Core.subtract(grayImg1,img1mean,grayImg1);
click to hide/show revision 6
retagged

updated 2018-07-03 07:52:18 -0600

berak gravatar image

subtract method replace negative values with zeros

I am doing subtraction of grayscale images. i want to keep negative values. but subtract method in opencv replace negative values with zeros. User Mat types are CV_32S, CV_32F.

public double corr2(Mat img1, Mat img2){

        Mat grayImg1,grayImg2;
        grayImg1=new Mat(300,300,CV_32S);
        grayImg2=new Mat(300,300,CV_32S);
        Imgproc.cvtColor(img1,grayImg1,COLOR_RGB2GRAY);
        Imgproc.cvtColor(img2,grayImg2,COLOR_RGB2GRAY);
        Scalar img1mean=Core.mean(grayImg1);
        Scalar img2mean=Core.mean(grayImg2);
        Core.subtract(grayImg1,img1mean,grayImg1);