What's the difference between imagesc and imshow?

174 ビュー (過去 30 日間)
Matlab Help Seeker
Matlab Help Seeker 2013 年 4 月 15 日
コメント済み: Image Analyst 2022 年 5 月 22 日
Hi,
When I want to display an image in figure screen, both works the same way. I was wondering what's the difference between both imagesc and imshow commands?
Thank you.

採用された回答

Adam Filion
Adam Filion 2013 年 4 月 15 日
imshow has a number of default settings intended for displaying images, such as turning off the axes and locking the aspect ratio, that imagesc does not. imshow also had additional options for customizing how you view the image that are not available or not as easily doable through imagesc. You can see the basic differences by doing something like the following and looking at the two figures side by side.
>> imagesc(myimage)
>> figure
>> imshow(myimage)
You can get full details on the functions and their usages through their documentation pages.
>> doc imagesc
>> doc imshow
Finally you can view the source code for both if interested.
>> edit imagesc
>> edit imshow
  3 件のコメント
Anand
Anand 2014 年 2 月 12 日
I presume you're talking about the fact that the image is not magnified. This is because imshow by default displays images at 100% magnification. If you would like to change that behavior, you can update the preferences for imshow as follows:
iptsetpref('ImshowInitialMagnification','fit');
You can reset this to the default using
iptsetpref('ImshowInitialMagnification',100);
Walter Roberson
Walter Roberson 2020 年 12 月 24 日
You can
imshow(image, [])
to have it scale the data the way imagesc() does.

サインインしてコメントする。

その他の回答 (2 件)

pouria farhadian
pouria farhadian 2018 年 4 月 30 日
imagesc reduce the time of our process.actually I dont know why????
  3 件のコメント
Ying Yu
Ying Yu 2020 年 12 月 24 日
Practically, I actually think pouria's answer is quite valuable. Thanks!
Walter Roberson
Walter Roberson 2020 年 12 月 24 日
imagesc() does less work than imshow(), and changes fewer graphics settings, so it is not as "hard" on the graphics system.

サインインしてコメントする。


Mehri Mehrnia
Mehri Mehrnia 2022 年 5 月 22 日
I work with cardiac MRI images(grayscale). it happens repeatedly that "imagesc" shows the image while "imshow" shows a nonsence combination of black-white point!!
I don't know the reason. Any thought?
  1 件のコメント
Image Analyst
Image Analyst 2022 年 5 月 22 日
You probably have a floating point image with values outside the range of 0 to 1. Therefore you need to use [] in imshow(
imshow(mriImage, []);
That will take whatever the actual values are and scale them to 0-255 for display. Otherwise values below 0 show as black and above 1 show as white.
imagesc automatically scales the image -- that's what the "sc" stands for. However it applies a colormap that produces a pseudocolored RGB image that is almost always not what you want. imshow() leaves it as gray scale.
With either function you can apply the colormap you want, either with the 'Colormap' option of imshow(). Or you can call the colormap() function for either imshow() or imagesc() as a function call after you call them.
cmap = turbo(255);
colormap(cmap);
colorbar

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDisplay Image についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by