필터 지우기
필터 지우기

How to convert matrix into image ?

조회 수: 129 (최근 30일)
bavani marimuthu
bavani marimuthu 2018년 1월 4일
댓글: Walter Roberson 2020년 3월 11일
Please tell How to convert matrix into image ?
Is this Code correct :
str ='Hello'
a = double(str)
K = mat2gray(a); # which converts the matrix into image
min_image = min(K(:))
max_image = max(K(:))
figure
imshow(K)
  댓글 수: 7
bavani marimuthu
bavani marimuthu 2018년 1월 6일
Yeah I want to embed the message in an image?? Please help..
Jan
Jan 2018년 1월 6일
@bavani: It is hard to help you, if you explain only vaguely, what you want. "embed the message in an image??" Maybe a dot is better than two question marks. You got the suggestion to search in the FileExchange, because you find working examples there. Did you do this already? How can we help you, if you do not ask a specific question?

댓글을 달려면 로그인하십시오.

답변 (4개)

Walter Roberson
Walter Roberson 2018년 1월 4일
imagesc(K)
or
imshow(K, [])
  댓글 수: 3
Image Analyst
Image Analyst 2020년 3월 11일
Dyhia, not sure what you mean. The image already IS a matrix.
Walter Roberson
Walter Roberson 2020년 3월 11일
scaled_K = mat2gray(K);
Or in newer versions of MATLAB,
scaled_K = rescale(K);

댓글을 달려면 로그인하십시오.


Jan
Jan 2018년 1월 4일
Is hard to answer this, because as far as I understand, there is no problem at all. Images are matrices, so what exactly is the problem?
It looks really strange, that your the input data is the converted char vector 'Hello', but of course it is valid. You did not mention, why you obtain the minimal and maximal values, and I cannot guess, how this is useful. You post some code, which looks okay, so do you have any problems with it?
str = 'Hello'
a = double(str);
gray = a / 255;
figure;
imshow(gray, 'InitialMagnification', 'fit')
mina = min(a(:));
maxa = max(a(:));
grayUINT8 = uint8((a - mina) * 255 / (maxa - mina));
figure;
imshow(grayUINT8, 'InitialMagnification', 'fit')
Does this help in any way to display your 1 x 5 pixel image in gray scalar, at first as double and at second as scaled UINT8?

Image Analyst
Image Analyst 2018년 1월 6일
If you have coding questions, reply here, not in the File Exchange, but only after you read this link.

Bilal Habib
Bilal Habib 2020년 2월 19일
a = imread('Rose-flower.jpg');
subplot(2,3,1);
imshow(a);
c = rgb2gray(a);
subplot(2,3,2);
imshow(c)
% Class Task:
h =[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20];
imshow(h)
i = uint8(h);
imshow(i)
i do not understand that how to get image in using matrix....what is reason...? You can fix code...
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 2월 19일
imshow(i) is correct but it will be dark because you only use brightness 20 out of 255. Try
imshow(i, [])

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by