How can I generate an image from a matrix?

2 ビュー (過去 30 日間)
Cesar
Cesar 2013 年 2 月 2 日
The image would be 3 x 3 with the colors as shown below. The other can stay white.
Red Yellow
Green
Green Blue
  2 件のコメント
Jan
Jan 2013 年 2 月 2 日
Deleted questions are annoying.
Randy Souza
Randy Souza 2013 年 2 月 12 日
I have restored the original text of this question.
Cesar, this question has a clear subject and an accepted answer, so it may be valuable to someone else in the future. If you have a good reason why it should be removed from MATLAB Answers, please flag the question, explain why it should be deleted, and an administrator or high-reputation contributor will consider deleting the question. Please do not simply edit your question away.

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

採用された回答

Walter Roberson
Walter Roberson 2013 年 2 月 2 日
編集済み: Walter Roberson 2013 年 2 月 2 日
Red = [255 0 0];
Yellow = [0 255 255];
Green = [0 0 255];
Blue = [0 255 0];
Im = uint8(255) * ones(3,3,3,'uint8');
Im(1,1,:) = Red;
Im(1,3,:) = Yellow;
and so on.
  2 件のコメント
Cesar
Cesar 2013 年 2 月 2 日
編集済み: Walter Roberson 2013 年 2 月 2 日
Did not work. I continue on as shown below. The image is extremely small and the colors did not come out right. See below:
EDU>> Red = [255 0 0];
EDU>> Yellow = [0 255 255];
EDU>> Green = [0 0 255];
EDU>> Blue = [0 255 0];
EDU>> Im = uint8(255) * ones(3,3,3,'uint8');
EDU>> Im(1,1,:) = Red;
EDU>> Im(1,3,:) = Yellow;
EDU>> Im(2,2,:) = Green;
EDU>> Im(1,3,:) = Green;
EDU>> Im(3,3,:) = Blue;
EDU>> figure, imshow(Im)
EDU>> imshow(Im)
EDU>> figure, imshow(Im)
Walter Roberson
Walter Roberson 2013 年 2 月 2 日
Of course the image is extremely small. You asked for a 3x3 image. 3 pixels by 3 pixels.
I should have used [255 255 0] for yellow.

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

その他の回答 (2 件)

Youssef  Khmou
Youssef Khmou 2013 年 2 月 2 日
Hi, add the property 'notruesize' to imshow function :
imshow(Im,'notruesize');
  3 件のコメント
Youssef  Khmou
Youssef Khmou 2013 年 2 月 2 日
I have no idea about the 255,0 arrangement for RGB, verify that repartition you gave,
Youssef  Khmou
Youssef Khmou 2013 年 2 月 2 日
i am trying to write a function for that purpose, i think you gave wrong colors .

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


Youssef  Khmou
Youssef Khmou 2013 年 2 月 2 日
Here is your solution :
Red = [255 0 0];
Yellow = [255 255 0];
Green = [0 0 255];
Blue = [0 255 0];
Im = uint8(255) * ones(3,3,3,'uint8');
Im(1,1,:) = Red;
Im(1,3,:) = Yellow;
Im(2,2,:)=Blue;
Im(3,1,:)=Blue;
Im(3,3,:)=Green;
window=ones(100,100,'uint8');
RED=kron(Im(:,:,1),window);
GREEN=kron(Im(:,:,2),window);
BLUE=kron(Im(:,:,3),window);
FINAL=ones(300,300,3,'uint8');
FINAL(:,:,1)=RED;
FINAL(:,:,2)=GREEN;
FINAL(:,:,3)=BLUE;
figure, imshow(FINAL)
This a clever way to multiply 3x3x3 to get 300x300x3 .
  4 件のコメント
Youssef  Khmou
Youssef Khmou 2013 年 2 月 2 日
what's the prob here?
Walter Roberson
Walter Roberson 2013 年 2 月 2 日
A bit too much help given on a homework problem.

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

カテゴリ

Help Center および File ExchangeGeometric Transformation and Image Registration についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by