Iam new to MATLAB and Iam trying to do arithmetic operation upon two Images without using the matlab functions like" imdd,imsub​tract,immu​ltiply,imd​ivide". Can any one suggest me how to perform scaling on the resultant image.

1 view (last 30 days)
Thanks in advance!

Accepted Answer

Vijay
Vijay on 30 Sep 2013
Thanks for your replies!
I dont know wheather imdouble() works or not. I just now managed to write code for arithmetic operations on two same type and same sized images. thank you!

More Answers (2)

Walter Roberson
Walter Roberson on 30 Sep 2013
Edited: Walter Roberson on 30 Sep 2013
im2double(), then do the arithmetic operation. But you need to describe how you want to transform the result into an image, as addition or subtraction or division of floating point numbers that start off in the range [0, 1] might often end up with an arithmetic result that is not in [0, 1]
  3 Comments
Walter Roberson
Walter Roberson on 30 Sep 2013
for multiplying of images that are in the range [0, 1], you do not need to do anything to turn the result back into an image, other than displaying the array using image() or imshow()
For addition or subtraction or division, you need to decide what you want to do with values that fall outside the range [0, 1]. There is no one "right" way to do it, as it depends on your intent.

Sign in to comment.


Image Analyst
Image Analyst on 30 Sep 2013
I just use double(). I can't stand im2double with it's unclear "rescaling the data if necessary." feature. Nowhere in the help do they actually explain what that actually means. It seems that when I've used it in the past, sometimes it leaves values the same and other times it scaled everything to the range 0-1. It seemed so inconsistent with no explanation whatsoever of when it will scale and when it won't, and how it does the scaling, so I refuse to use it now. If there's any scaling to be done, I'll do it myself, thank you very much. At least I know what I did. I never use its equally confusing friends either, such as imsubtract(), etc.

Community Treasure Hunt

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

Start Hunting!