I have an image that I load from a file. Is it a .png. I convert this to a 1D array for use in a function via a pointer to the array. When I create a Mat from the 1D pointer, the resulting image looks like it takes the right-most dozen or so columns, and puts them on the left side of the image, almost like a circular shift of columns.
// SAMPLE CODE
Mat img = imread(argv[1], CV_LOAD_IMAGE_ANYDEPTH); // 16U1 png
int ncols = img.cols;
int nrows = img.rows;
//--Create input array and pointer--
uint16_t rawImage[nrows*ncols];
uint16_t *rawImage_ptr = rawImage;
//Assign value to array
for (int i=0;i<(ncols*nrows);i++){
*(rawImage_ptr+i) = img.at<uint16_t>(i);
}
// Create Mat from pointer
Mat image(nrows, ncols, CV_16UC1, &rawImage_ptr);
The result 'image' has some of the right columns wrapped around to the left. Any idea what is going on here?