I'm trying to write a code on image compression.
I = imread('cameraman.bmp');
I = im2double(I);
T = dctmtx(8);
dct = @(block_struct) T * block_struct.data * T';
B = blockproc(I,[8 8],dct);
whenever i try to execute the above line, I encounter with an error as
error: matrix cannot be indexed with .
error: called from
@<anonymous> at line 1 column 45
blockproc at line 135 column 6
please help me with this. thanks.
@anonymous> at line 1 column 45
It wrote that the error in the position of "block_struct.data".
The error happens because your block_struct is a matrix (for example, [1 2; 3 4]) and it is not callable object (in other words, "block_struct." is forbidden).
Try to delete ".data".
I had similar issue resolved by correcting multiplication calculation. Assuming here 'data' is a variable that is multiplied to block_struct
Change block_struct.data to block_struct * data In Matrix calculation * is used instead of dot notation.
hope it helps. JSH
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With