Keeping only non-zero elements in cv::Mat
Hi,
I´ve got a problem trying to get rid of the zero valued elements in matrix. I want to remove them and keep only non-zero elements in it.
Example: Mat: [1,2,3,0,0,0,4,5,6,0,0,0...] --> [1,2,3,4,5,6,...]
What would be the easiest and fastest way to do it? I have looked into SparseMat, but does not seem to work. Any other solutions? If it is possible to do it directly in GpuMat before downloading the results to cv::Mat, it would be even better.
Thanks!