How to create image from a matrix?

78 ビュー (過去 30 日間)
Boni_Pl
Boni_Pl 2019 年 8 月 30 日
コメント済み: Image Analyst 2019 年 8 月 31 日
Hello, I have an matrix whose dimension is 101x4032 double. Now how can I see the image using imshow function? Please help me.

回答 (2 件)

Image Analyst
Image Analyst 2019 年 8 月 30 日
If m is your double matrix, use
imshow(m, []);
This works for any range of m - it doesn't have to be in the 0-1 range. Though if it already is in the 0-1 range, then you can omit the [] input argument to imshow().
  2 件のコメント
Boni_Pl
Boni_Pl 2019 年 8 月 31 日
Sir Can I make this matrix as square matrix such as 500x500?
Image Analyst
Image Analyst 2019 年 8 月 31 日
You can use imresize():
resizedImage = imresize(originalImage, [500, 500]);
though be aware that there will be a different number of pixels in the new matrix and they won't have exactly the same values though they may be close.

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


Star Strider
Star Strider 2019 年 8 月 30 日
Try this:
A = randn(101,4032); % Create Matrix
B = uint8(A);
figure
imshow(B,[])
There are likely better ways to display your matrix, such as image or imagesc.
  2 件のコメント
Image Analyst
Image Analyst 2019 年 8 月 30 日
Why might those be likely to be better? I never use those instead of imshow().
Star Strider
Star Strider 2019 年 8 月 31 日
You cannot reshape your matrix into a square matrix.

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

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by