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

1 vue (au cours des 30 derniers jours)
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.

Réponse acceptée

Stephen23
Stephen23 le 29 Fév 2016
Modifié(e) : Stephen23 le 29 Fév 2016
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.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by