matrix dimensions must agree error
1 view (last 30 days)
Show older comments
Lefteris Kostakis
on 22 Nov 2019
Commented: Image Analyst
on 22 Nov 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 Comments
Accepted Answer
Image Analyst
on 22 Nov 2019
Edited: Image Analyst
on 22 Nov 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 Comments
Image Analyst
on 22 Nov 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.
More Answers (0)
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!