Ask Your Question

hyun's profile - activity

2020-03-12 02:08:54 -0600 received badge  Popular Question (source)
2018-09-14 11:42:38 -0600 received badge  Nice Question (source)
2014-11-03 18:36:28 -0600 commented answer Increase the maximum amount of channels in cv::Mat

you meant int sz[] = {100, 100, 100}; Mat bigCube(3, sz, CV_8U, Scalar::all(0));

instead of Mat bigCube(100,100,CV_32FC(100));

I appreciate your help.

2014-11-03 18:16:52 -0600 received badge  Editor (source)
2014-11-03 16:13:11 -0600 received badge  Student (source)
2014-11-03 15:37:16 -0600 asked a question Increase the maximum amount of channels in cv::Mat


In my current work, I need to represent an input image (e.g. 200x200 color) as a matrix of feature vectors extracted from fixed sub-regions of the image. So the final feature representation forms a matrix with Col * Row * Depth dimensional size, where Col and Row are always smaller than the original size(i.e. 200* 200), and the Depth (channel) needs to be 512, 1024, ..., up to 8192. And the feature is already extracted and stored in a text file offline, so all I have to do is just declare a cv::Mat variable and initialize it with values loaded from the text file. But one problem was that maximum amount of channels of cv::Mat is currently defined and limited to 512 by constant CV_CN_MAX, as mentioned in So I tried to modify the constant and recompiled the opencv and my programs, and it seems to be able to accommodate higher channel such as 1024, 2048, and so on. But after I increase the constant, I have matrix computation results different from before the constant modification, even though I've used same feature text file and same numerical operation. For example, if the dot product of two feature vectors (row==1, col==1) and (row==2, col==2) was "1.1", then I expected the result must be same for the same feature vectors and dot product operation after the constant modification, but it wasn't. Also the computation time and memory usage have been drastically increased. I guess CV_CN_MAX not only influence on the maximum amount of channels, but also something else in opencv.

So my question is that is there another way to represent a high-depth (e.g. 4096 and 8192) matrix other than modifying CV_CN_MAX? If no, then what else would I need to look at to solve this issue? Sorry for the non-straightforward question :(