matrix dimensions must agree error

1 visualización (últimos 30 días)
Lefteris Kostakis
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?

Respuesta aceptada

Image Analyst
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
Lefteris Kostakis
Lefteris Kostakis el 22 de Nov. de 2019
W 144x176 double (the parameter in function is array frame178 and its also 144x176 but not double it is uint8)
M 4x4 double
q 1x1 double
Image Analyst
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by