Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matrix cannot be indexed with

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.

like image 476
Shriya Shigli Avatar asked Oct 08 '17 06:10

Shriya Shigli


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".

like image 135
Nick Veld Avatar answered Oct 23 '22 03:10

Nick Veld


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

like image 31
JSH Avatar answered Oct 23 '22 04:10

JSH