4
votes

I am quite new to matlab/octave. I loaded an image using imread() function of octave. I tried to perform multiplication operation on the matrix but get the following error:

binary operator `*' not implemented for `uint8 matrix' by `matrix' operations 

Is there another way to input the image??

3
Can you please post your full code? - Dyrborg
Try to covert the image to "double" format, by the function double. - Adiel

3 Answers

11
votes
I=imread('...');
I=rgb2gray(I);
I=double(I);
% you can perform the multiplication operation now
2
votes

This usually means that you are trying to multiply arrays of different data types. The easiest thing to do here is to convert the uint8 image into double. You can either use the double() function, which will just cast the values, or us im2double(), which will also normalize the values to be between 0 and 1.

2
votes

If you're trying to multiple two images (I'm guessing that's what you're trying to do since the error is for multiplying matrices and not a matrix by a scalar), you should use the immultiply function which handles different classes for you.

Simply, use immultiply (imgA, imgB) and never again worry about what class are imgA and imgB. Note that you'll need the image package installed in loaded.