matrix dimensions must agree error
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Lefteris Kostakis
el 22 de Nov. de 2019
Comentada: Image Analyst
el 22 de Nov. de 2019
%I want to use dct2 to an image array and quantize 4x4 blocks of the image
%but in [afteral]=quantization(imafter,25); command it says "matrix dimensions must agree"
%IGNORE integer_transform its just another function I use.
frame178=imread("frame178.tif");
quantize = @(block_struct) integer_transform(dct2(block_struct.data));
imafter = blockproc(frame178,[4 4],quantize);
[afteral]= quantization(imafter,25);
%the function :
function [Z] = quantization(W,QP)
Z = round(W.*(M/2^q));
%THIS IS THE FUNCTION DEFINITION AND THE LINE WHERE IS THE ERROR
%M and q are defined before in the function M is a matrix with some factors and q is an integer
%I assume Z the error is the inserted matrix M that is different size from Z but when I do
%multiply with x.*y dont I multiply all elements of an array(W) with an integer from a matrix(M)? so why to have size error there?
0 comentarios
Respuesta aceptada
Image Analyst
el 22 de Nov. de 2019
Editada: Image Analyst
el 22 de Nov. de 2019
It's not Z that matters. It's W.
What does this report in the command window if you put it before that Z line:
whos W
whos M
whos q
2 comentarios
Image Analyst
el 22 de Nov. de 2019
So why do you think it's okay to do an element-by-element operation of a 144x176 matrix by a 4x4 matrix?
What happens when it goes to multiply W(5, 1) by M(5, 1) when there is no M(5,1)?
It can't multiply elements when the elements are not there.
Más respuestas (0)
Ver también
Categorías
Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!