Ask Your Question
0

divide double[] into double factor

asked 2014-07-02 23:49:49 -0600

rafaoc gravatar image

updated 2020-08-13 16:16:35 -0600

Hi, I am working with opencv in java.
I have a cvMat element with three elements and I want to divide the first and the third element in order to get just the double value.
Using < T.get(0, 0) > I get a data type double[]
I have tried to make as follow
double div = T.get(0, 0) / T.get(2, 0);
or just
double div = T.get(0, 0) / 2.0d
but neither the first nor the second one are allowed

How could I do that ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-07-03 04:28:56 -0600

Hi @rafoc

If you have a Mat like this & if you want to find the divided result of Blue & Red Intensity You can do like this.

Mat InputImage= Mat::zeros(640,480,CV_32FC3);
Mat DividedResult= Mat::zeros(640,480,CV_32FC1);
for (int Row = 0; Row < InputImage.rows; Row++)
{
    for (int Col = 0; Col < InputImage.cols; Col++)
    {
        Vec3f PixelValue= InputImage.at<Vec3f>(Row,Col);
        DividedResult.at<float>(Row,Col)= PixelValue.val[0]/PixelValue.val[2];// Blue Intensity / Red Intensity
    }
}
edit flag offensive delete link more

Comments

Thanks for your answer although you're programming in c++ and me in java. I got an idea

double div =  T.get(0, 0)[0] / T.get(2, 0)[0] ;
rafaoc gravatar imagerafaoc ( 2014-07-03 14:24:54 -0600 )edit

Question Tools

Stats

Asked: 2014-07-02 23:49:49 -0600

Seen: 235 times

Last updated: Jul 03 '14