Multiplying matrices of different classes
14 ビュー (過去 30 日間)
古いコメントを表示
In my applied math course, we're learning wavelet compression techniques, and my partner and I have so far constructed two matrices. One matrix is the wavelet transform - a 256*256 orthogonal matrix, class = double The other matrix is constructed by the imread command and is a 256*256 matrix, class = uint8
naturally, when I multiply these two matrices together, I get an error code. "MTIMES is not fully supported for integer classes. At least one input must be scalar."
This is my first time using matlab and using the user community. There is not a lot of direction from the instructor, so maybe I could get help on creating code for the next part of the project. To compress the resulting matrix, we need to order the elements from highest to lowest, and find the number of terms that satisfy (L1^2 +L2^2 +...+Lk^2)/ (total energy of the system) greater than or equal to .99
This project is the hardest I've ever worked on, and I'm not a whiz at computer science. Hopefully, I receive sufficient help. Thanks in advance.
0 件のコメント
回答 (3 件)
James Tursa
2014 年 11 月 5 日
編集済み: James Tursa
2014 年 11 月 5 日
For the first part of your question, to do a matrix multiply:
a = your double matrix
b = your uint8 matrix
c = a * double(b);
If you really wanted to do an element-wise multiply, then you would use .* instead. E.g.,
a = your double matrix
b = your uint8 matrix
c = a .* double(b);
Regarding the "compressing" issue. It is not clear how you want this done. Could you be more specific with some equations for how the c matrix is related to your (L1^2 +L2^2 +...+Lk^2)/ (total energy of the system) expression?
0 件のコメント
Brian
2014 年 11 月 5 日
2 件のコメント
James Tursa
2014 年 11 月 5 日
I still don't get the connection. Is L1 = c(1,1), or is L1 = largest value in c matrix, or what? How specifically is the c matrix (the result of the matrix multiply) related to L1, L2, etc?
Brian
2014 年 11 月 5 日
1 件のコメント
Ian Syndergaard
2022 年 2 月 11 日
I realize that I'm way late to answer this, but perhaps someone else will find this helpfull:
Your 256x256 image has a red layer, a green layer, and a blue layer. These three "layers" are stored in that 3rd dimension of your matrix.
There are two options:
1. You could compress each color layer individually by extracting the different color layers as follows:
photo_data = imread("photo_file.jpg");
red_layer = photo_data(:,:,1);
green_layer = photo_data(:,:,2);
blue_layer = photo_data(:,:,3);
2. You could create a greyscale image by simply using one of the three colors or by averaging the three colors as follows:
photo_data = imread("photo_file.jpg");
greyscale_data = uint8(mean(photo_data));
参考
カテゴリ
Help Center および File Exchange で Continuous Wavelet Transforms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!