MATLAB: Error using .* Integers can only be combined with integers of the same class, or scalar doubles.

error using *integers combined with integers of the same classmean

How can I add a weighted version of an image to the original image to create a sharpened image. I did:
image1 = imn'.*mean(image,2);
figure, imshow(image);
but something it is wrong..
Error using .* Integers can only be combined with integers of the same class, or scalar doubles.

Best Answer

Assuming that imn and image are both of the same integer class, then use the third input argument of mean:
mean(image,2,'native')
Then mean will return values of the same class as the input image, which can then be multiplied with imn (also of the same integer class).
Or, if you want to retain any fractional values, simply convert all of the images to double before performing your calculation.
Important DO NOT call any variable image, as this is the name of a very important and useful function image, which will stop working when you use that name. For the same reason do not use cell, size, i, j, length, etc.