I want to create an image using a matrix.

1) Suppose i have a (8x8) matrix and i want this matrix to be converted into image (as shown in below image).
Note that each row of the matrix correspond to the each row of color in the image.
2) Also if i have R,G,B matrix, then how can i create the image (as shown in below image)

10 comentarios

Jason Moore
Jason Moore el 11 de Feb. de 2015
Is the imwrite function what you are looking for? imwrite has the ability to take a file name argument and a matrix for your RGB colors and write them to the file format of your choosing.
Nikhil Chourasia
Nikhil Chourasia el 13 de Feb. de 2015
Editada: Nikhil Chourasia el 2 de Mzo. de 2015
Great Sir, its working. But i have to divide all my matrix value by 255. After that when i used imwrite function it create image in the shades of black only (as seen in below image)
I tried changing my matrix value but it does'nt make much difference. What i need is to create image equivalent to R,G,B code.
Image Analyst
Image Analyst el 13 de Feb. de 2015
Nikhil, for #1, can you give us the 8 by 8 matrix . I'm not clear how a 8 by 8 matrix (64 elements) can go into a much larger image that has colors and gray frames. Where are you getting the colors from? And what does the 8 by 8 matrix have to do at all with the output image? And how thick are the gray stripes, and how big do you want the overall image to be?
For #2, there is no " image below ". Please edit your post to insert it, just like you did with the image for #1 - by using the green and brown frame icon.
Image Analyst
Image Analyst el 2 de Mzo. de 2015
Nikhil, it's not clear what your edit was. What did you change?
Nikhil Chourasia
Nikhil Chourasia el 2 de Mzo. de 2015
Editada: Nikhil Chourasia el 3 de Mzo. de 2015
Actually Sir my 8x8 matrix is generating very small image (approx. 400 bytes size ). The above image is for 10x10 matrix which is also approx. 400 bytes.
Nikhil Chourasia
Nikhil Chourasia el 3 de Mzo. de 2015
Sir I have only reinserted image For#2.
Nikhil Chourasia
Nikhil Chourasia el 3 de Mzo. de 2015
Editada: Nikhil Chourasia el 4 de Mzo. de 2015
I again try to put my question in more clear way.
I want to create an image equivalent to a no. so that i can use that image as a code (as a watermark). For example my input no. is [0 1 2 3 4 5 6 7 8 9] and i want to create image equivalent to this no. in the form of RGB color. I am using 'repmat' to replicate my input no. to form a bigger matrix.
HEM RAJ
HEM RAJ el 4 de Mzo. de 2015
Editada: HEM RAJ el 4 de Mzo. de 2015
U cannot obtain RGB image untill your matrix is 3 dimensional. First create a Three dimensional matrix I with (8,8,3) dimensions . where I(:,:,1) corresponds to red channel. means according to image shown u need for the I(1,:,1) higher values as compared to the values in I(1,:,2)and I(1,:,3). for second row I(2,:,2) should be greater then blue and red components. For third row blue values should be higher it means I(3,:,3) should have higher values than I(3,:,1) and I(3,:,2).
Nikhil Chourasia
Nikhil Chourasia el 8 de Mzo. de 2015
Editada: Nikhil Chourasia el 8 de Mzo. de 2015
HEMRAJ thanks for your help. I am able to create image. But the image is too small and only a single strip . I want to create strips of color equivalent to my input no. Below is my code which i used.
Matrix1 =[0 0 0]
Matrix2 =[1 1 1]
Matrix3 =[0 0 0]
[m,n]=size(Matrix1);
my_image=[m,n,3];
my_image(:,:,1)=Matrix1;
my_image(:,:,2)=Matrix2;
my_image(:,:,3)=Matrix3;
imshow(my_image);
Please suggest how i can create image like this
Please note color may vary this is only example of image
Nikhil Chourasia
Nikhil Chourasia el 10 de Mzo. de 2015
Thank U all for your help. I am now able to create image using RGB values. But how can i directly give input of R,G,B values in uint8 instead of double.

Iniciar sesión para comentar.

 Respuesta aceptada

Eduardo Márquez
Eduardo Márquez el 13 de Feb. de 2015
Editada: Eduardo Márquez el 13 de Feb. de 2015

1 voto

Using:
imwrite(A,'Image.jpg')
where A is a matrix 3D, A(:,:,1) = Red channel, A(:,:,2) = Green Channel, A(:,:,3) = Blue Channel;

1 comentario

Nikhil Chourasia
Nikhil Chourasia el 10 de Mzo. de 2015
Thank U Eduardo Márquez for your help. I am now able to create image using RGB values. But how can i directly give input of R,G,B values in uint8 instead of double.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Images en Centro de ayuda y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by