How to save matrix to workspace instead of plotting using imagesc function

3 views (last 30 days)
Naz
Naz on 25 Jun 2012
Commented: Neda on 28 Sep 2017
I don't understand how imagesc function works (scales), but my images plotted using via that function look better than using imshow. Is there any way to save the scaled image in the workspace instead of displaying it? I tried to debug built-in imagesc.m, but found nothing that scales data. If anyone knows how it's done, please, let me know.

Accepted Answer

Walter Roberson
Walter Roberson on 25 Jun 2012
If M is your image, then
minM = min(M(:));
maxM = max(M(:));
scaledM = (M - minM) ./ (maxM - minM);
This will be in the range 0 to 1, so if you want to work with uint8 then uint8(scaledM .* 255)
  8 Comments

Sign in to comment.

More Answers (0)

Categories

Tags

Community Treasure Hunt

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

Start Hunting!