Display a small matrix as a gray scale image
14 views (last 30 days)
Show older comments
I have a small text file called "my_img_data.txt".
I want to display it as a grey scale image.
I am using
>>T1 = load('my_img_data.txt')
T1 =
120 250 214 82
250 214 82 120
214 82 120 250
250 214 82 120
T2 = T2 = mat2gray(T1,[0 255])
>>T2 =
0.4706 0.9804 0.8392 0.3216
0.9804 0.8392 0.3216 0.4706
0.8392 0.3216 0.4706 0.9804
0.9804 0.8392 0.3216 0.4706
>> imshow(T2)
It displays an image in gray scale, but only as 4x4 pixels out of something like 256x256, so I can hardly see it. How can I make it so it shows just the 4x4 pixels?
By the way, if I use image(T1), I get just the 4x4 pixels, but it's a color map. I want grey scale.
Thank you,
Maarten
0 Comments
Accepted Answer
Matt J
on 5 Mar 2025
T2 =[
0.4706 0.9804 0.8392 0.3216
0.9804 0.8392 0.3216 0.4706
0.8392 0.3216 0.4706 0.9804
0.9804 0.8392 0.3216 0.4706];
imagesc(T2); colormap(gray(256)); colorbar
3 Comments
More Answers (1)
Image Analyst
on 6 Mar 2025
T2 =[
0.4706 0.9804 0.8392 0.3216
0.9804 0.8392 0.3216 0.4706
0.8392 0.3216 0.4706 0.9804
0.9804 0.8392 0.3216 0.4706];
imshow(T2, 'InitialMagnification', 10000); % Adjust number as needed.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

