C++AMP Computing gradient using texture on a 16 bit image

一曲冷凌霜 提交于 2019-12-02 03:31:33

Your indexes are swapped in two places.

int x = idx[0];
int y = idx[1];

Remember that C++AMP uses row-major indices for arrays. Thus idx[0] refers to row, y axis. This is why the picture you have for "For x" looks like what I would expect for texR.set(idx, valY).

Similarly the extent of image is also using swapped values.

int valX = (x / (float)imageSize[0]) * 65535;
int valY = (y / (float)imageSize[1]) * 65535;

Here imageSize[0] refers to the number of columns (the y value) not the number of rows.

I'm not familiar with OpenCV but I'm assuming that it also uses a row major format for cv::Mat. It might invert the y axis with 0, 0 top-left not bottom-left. The Kinect data may do similar things but again, it's row major.

There may be other places in your code that have the same issue but I think if you double check how you are using index and extent you should be able to fix this.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!