How can I convert an integer matrix to a real-valued matrix to perfrom SVD

1 view (last 30 days)
A = imread('image');
SVD = svd(A)

Answers (1)

John D'Errico
John D'Errico on 14 Feb 2022
help double
DOUBLE Convert to double precision. DOUBLE(X) returns the double precision value for X. If X is already a double precision array, DOUBLE has no effect. DOUBLE is called for the expressions in FOR, IF, and WHILE loops if the expression isn't already double precision. DOUBLE should be overloaded for all objects where it makes sense to convert it into a double precision value. See also SINGLE, DATATYPES, ISFLOAT, ISNUMERIC. Documentation for double doc double Other functions named double categorical/double duration/double quaternion/double codistributed/double filtstates/double StaticModel/double dataset/double gpuArray/double string/double datetime/double opaque/double tabular/double dlarray/double
  2 Comments
John D'Errico
John D'Errico on 14 Feb 2022
Um, so? Your point is what? I presumed that since you knew what you wanted to do, then you understood enough about the SVD to know that it is meaningless to try to apply it to a 3-d matrix. Therefore your image must already be a single channel image.
So let me go back. You cannot compute the SVD of a 3-d matrix. That is meaningless. So YOU need to decide what you will compute the SVD on. And only you can decide that.
If, for example, you wanted to compute the SVD of only the red channel, that would be trivial. Or the green, or the blue channels. Just extract the indicated channel, then convert to double, then compute the SVD.
Up to you, entirely so. Or, perhaps you wanted to compute the SVD of the image as a greyscale matrix. So convert to grey FIRST, and THEN convert to a double array. At that point, the image will be only a single channel, so amenable to a SVD.
Or you might decide to convert the entire image to a color space like LAB. THEN compute the svd of L*, etc. Again, your choice.
Or, you might decide to reshape the matrix in some way to be a 2-dimensinal matrix. Again, only you know what and why you are doing this operation.
I'm sure there are other ways you might decide to transform the image into a 3D matrix. Just give me 10 seconds and I could think of a few more. But that would be again, your choice, because I'm pretty sure it is you who knows what it is you want to compute the SVD on, and why you are doing exactly that.

Sign in to comment.

Categories

Find more on Eigenvalues in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!