Ask Your Question
-1

please give me an example code for finding SVD of an image in C or C++ using opencv

asked 2013-09-12 00:12:57 -0600

Aparna J R gravatar image

I have tried to find out the SVD of an image in opencv and C/C++ using cvSVD(). But could'nt get the output. Can you please give an example code for finding SVD of an image in Opencv using C/C++ ??

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-09-12 01:00:36 -0600

Moster gravatar image

updated 2013-09-12 01:01:13 -0600

If you mean the Singular Value Decomposition its fairly simple. (c++ style) Although I dont really know what you want to do with the SVD of an image

cv::SVD svdMat(image);
edit flag offensive delete link more

Comments

Thank you.. But when did that code, I got an error like this..

OpenCV Error: Assertion failed (type == CV_32F || type == CV_64F) in _SVDcompute, file /build/buildd/opencv-2.3.1/modules/core/src/lapack.cpp, line 1453 terminate called after throwing an instance of 'cv::Exception' what(): /build/buildd/opencv-2.3.1/modules/core/src/lapack.cpp:1453: error: (-215) type == CV_32F || type == CV_64F in function _SVDcompute

Aborted (core dumped)

Aparna J R gravatar imageAparna J R ( 2013-09-12 04:24:57 -0600 )edit

Ye, obviously, cause your image will be of type uchar and not float or double. A singular value decomposition on an 8bit uchar will never work.

You need to convert your input image:

img.convertTo(imgConverted, CV_32F, 1.0/255) (or CV_64F)

Moster gravatar imageMoster ( 2013-09-12 05:12:26 -0600 )edit

It worked .. Thank you so much...

Aparna J R gravatar imageAparna J R ( 2013-09-13 01:25:43 -0600 )edit

Question Tools

Stats

Asked: 2013-09-12 00:12:57 -0600

Seen: 6,435 times

Last updated: Sep 12 '13