Matrix Multiplication Problem. Different Data Types.

This is sort of an extension of it.
My problem is, I do this:
A=imread(A) B=dct2(A) M=B*A*B'
Now, the final statement gives me an error since A is uint8 and B is double.
So what I did is, before the third step, I did: A=double(A)
Now, on doing imshow(A)...my entire image has changed from being that of a retina scan into a blank white image. I understand this is because of the type change, but the question is....will this cause any precision change in the multiplication that I am carrying out? After all, it is the value of M that is my main aim to find.
Also, on inserting a value in a 3D matrix array, I have to see the content of thousands of lines. Is there any way to stop that?

回答(2 个)

Instead of A = double(A), you can normalize the values to the intervall [0, 1]:
A = double(A) / 255
You can suppress the dispaly of the complete arrays by closing the statement with a semicolon:
A = rand(3);
A(1) = 5 % A is displayed
A(2) = 5; % A is not displayed
As I already indicated hours ago, instead of using double(A), I suggest you use im2double(A)
This is more general than Jan's solution in that im2double() will detect the proper scaling factor instead of assuming uint8.

类别

帮助中心File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

提问:

2011-8-4

Community Treasure Hunt

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

Start Hunting!

Translated by