Matrix cannot be indexed with

Viewed 6937

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.

2 Answers

@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

Related