Multiplying matrices of different classes
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (3)
James Tursa
el 5 de Nov. de 2014
Editada: James Tursa
el 5 de Nov. de 2014
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 comentarios
Brian
el 5 de Nov. de 2014
2 comentarios
James Tursa
el 5 de Nov. de 2014
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
el 5 de Nov. de 2014
1 comentario
Ian Syndergaard
el 11 de Feb. de 2022
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));
Ver también
Categorías
Más información sobre Continuous Wavelet Transforms en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!