Error using .* Integers can only be combined with integers of the same class, or scalar doubles.
2 views (last 30 days)
Show older comments
Thales Ferreira
on 29 Feb 2016
Commented: Thales Ferreira
on 29 Feb 2016
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.
0 Comments
Accepted Answer
Stephen23
on 29 Feb 2016
Edited: Stephen23
on 29 Feb 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.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!