Clear Filters
Clear Filters

MTIMES (*) is not fully supported for integer classes. At least one argument must be scalar., error in block struct BLOCKPROC encountered an error while evaluating the user-su

1 view (last 30 days)
n = input("enter the basis matrix dimension: ");
a = cell(n, n);
alpha2 = ones(1,n)*sqrt(2/n);
alpha2(1) = sqrt(1/n);
alpha1 = ones(1,n)*sqrt(2/n);
alpha1(1) = sqrt(1/n);
for u = 0:n-1
for v = 0:n-1
for x = 0:n-1
for y = 0:n-1
a {u+1,v+1}(x+1,y+1) = alpha1(u+1)*alpha2(v+1)*...
cos((2*x+1)*pi*u/(2*n))*cos((2*y+1)*pi*v/(2*n));
end
end
end
end
T = a;
disp(T);
for i = 1:n
for j = 1:n
dc = @(block_struct) T{i,j} * block_struct.data * T{i,j}';
B = blockproc(I,[8 8],dc);
end
end
  4 Comments
Walter Roberson
Walter Roberson on 16 Jul 2022
Side note: you can increase accuracy a little by using cospi() instead of cos()
cospi((2*x+1)*u/(2*n))*cospi((2*y+1)*v/(2*n))

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 16 Jul 2022
Edited: Walter Roberson on 16 Jul 2022
The message is correct. blockproc is extracting subsets of I, where I is uint8. Your function dc uses the * operator between some double precision data and the uint8 subset of I. However when you use working with uint8 data, you are only permitted to do arithmetic operations if both operands are uint8, or if one of the operands is a scalar double. uint8 combined with matrix of double is not permitted.
What datatype are you expecting the output to be?
Perhaps you need
dc = @(block_struct)
uint8( T{i,j} * double(block_struct.dat) * T{i,j}');

Community Treasure Hunt

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

Start Hunting!