opencv cv::mat not returning the same result -


    int sizeofchannel = (_width / 2) * (_height / 2);     double* channel_gr = new double[sizeofchannel];    // filling data channel_gr....      cv::mat my( _width/2, _height/2, cv_32f,channel_gr);             cv::mat src(_width/2, _height/2, cv_32f);     (int = 0; < (_width/2) * (_height/2); ++i)     {         src.at<float>(i) = channel_gr[i];            }     cv::imshow("src",src);     cv::imshow("my",my);     cv::waitkey(0); 

i'm wondering why i'm not getting same image in , src imshow
update: have changed array double* still same result; think steps?
image output enter image description here

src image output enter image description here

this 1 works me:

int halfwidth = _width/2; int halfheight = _height/2; int sizeofchannel = halfheight*halfwidth;  // ******************************* // // use cv_321fc1 later single precision float float* channel_gr = new float[sizeofchannel];  // filling data channel_gr.... for(int i=0; i<sizeofchannel; ++i) channel_gr[i] = i/(float)sizeofchannel;    // ******************************* // // changed row/col ordering, shouldnt important cv::mat my( halfheight , halfwidth , cv_32fc1,channel_gr);         cv::mat src(halfheight , halfwidth, cv_32fc1);   // ******************************* // // changed 1d indexing 2d indexing for(int y=0; y<src.rows; ++y) for(int x=0; x<src.cols; ++x) {     int arraypos = y*halfwidth + x;     // have 2d mat access in 2d     src.at<float>(y,x) = channel_gr[arraypos ];        }   cv::imshow("src",src); cv::imshow("my",my);  // check differences cv::imshow("diff1 > 0",src-my > 0); cv::imshow("diff2 > 0",my-src > 0); cv::waitkey(0); 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -