How to divide intensity values of one grayscale image to the intensity values of another grayscale image??

1 view (last 30 days)
Please help! I have two gray scale images. I want to divide each pixel value of one image with the corresponding pixel value of the other gray scale image.
Simply put, how to divide pixels of one gray scale image to the other?
Thanks.

Accepted Answer

Image Analyst
Image Analyst on 2 Sep 2014
If they're uint8, be sure to cast to double first or else you'll get clipping.
ratioImage = double(image1) ./ double(image2);
To display, use []:
imshow(ratioimage, []);
You can cast back to uint8 if you want, but that will lose fractions less than 1, so it should only be done when you know all the numbers will be well above 1.
ratioImage = uint8(ratioImage);
  1 Comment
Hamza Ahmed
Hamza Ahmed on 2 Sep 2014
Thanks for the advice Image analyst! I see why I was having problems with my result. After converting to double, it worked perfectly! Thanks

Sign in to comment.

More Answers (1)

Stephen23
Stephen23 on 2 Sep 2014
If each of your grayscale images is the same size matrix, then you can simply use the matrix right division . This also has the shorthand ./ .

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!