dct 2-D not working
Hello to all.I am trying to implement a cv::dct on c++ language inside visual studio 2012. My code is :
cv::dct(y_values,dct1); where y_values is an std::vector containing the Y values of an image (Y Cb Cr) , and dct1 is the std::vector for the output. Both are the same size (2-D) and their sizes are even numbers.
The error is: OpenCv error: Assertion failed (0 <= i && i < (int)(vv.size()) in cv::InputArray:getMat.
Thanks for your time
please show, how you get to y_values. also, those should be cv::Mat. there is a conversion between both, but we need to see your construct there, to find the error.
also, you will probably need to convert your input to float to apply dct/dft
Hello and thanks for your quick answer. The y_values is nothing more than a vector: std::vector< std::vector<int> > y_values(height, std::vector<int>(width)); , containing values. The extraction of the pixel values has not happened with open_cv library, so i only need to implement the dct using open_cv.
ah, ok,
vector<vector<int>>
will not work, you need consecutive (continuous) pixel data.try something like :
Seems very interesting. Even though how can i do the above with an std::vector<int> y_values (height * width); ??
yes, like:
I am sorry but i am kinda confused. I understand that this can be implemented with a Mat. But in documentation it mentioned also std::vector. The vector mentioned above is flat (1-D). So why do we need the Mat?
you can feed a std::vector to dct(), (it will be auto-converted to a cv::Mat) but in this case, it's only 1d, it does not know the shape of your original image.
also, again, float or double data needed
Thanks again for all your time. in your first example both ocv_y and dct_result would not be 1-D?
the 1st example is pushing rows of your
vector<vector<>>
into a Mat, expensive copy, but retaining the shape, the 2nd example keeps a pointer to the vector data, and builds a new 2d Mat header around itboth 2d, and the result will be 2d, too.
Thanks again. One last question: At some point at my program i want to access the Mat object's specific position as in std::vector vector1[i][j]. Is that possible? I get the error: expression must have pointer to object or handle-to-C++/CLI array type