Asked by Sivakumaran Chandrasekaran
on 26 Apr 2013

imread of an image will gives pixel values in the command window.. can we regenerate the same image from the pixel value?

Answer by Walter Roberson
on 26 Apr 2013

Accepted answer

imagedata = imread('YourImage.jpg'); imwrite(imagedata, 'YourNewImage.tif'); %can even change the image type

Sivakumaran Chandrasekaran
on 26 Apr 2013

imread can give values like [156 176 187...]..... does the same image is regenerated if i try imwrite([156 176 187...]...

Walter Roberson
on 26 Apr 2013

imwrite(uint8([156 176 187...]...)

If you used [156 176 187...] then the data class would be "double" (because that is the default for MATLAB), and that would be a problem, as MATLAB assumes that "double" values should have a range of 0 to 1 for images.

Related Content

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today
## 3 Comments

## Image Analyst (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/73659-can-we-able-to-generate-an-image-from-the-given-pixel-values#comment_145680

Seems like a rather odd question from a

university MATLAB course instructor( http://www.mathworks.com/matlabcentral/answers/62600#comment_127978). Certainly you already know that imread() doesnot necessarilygive the pixel values in the command window, unless you leave off the trailing semicolon. And you already know that an image is an array of numbers and that there are different types of images (uint8, double, color, indexed). So I'm not sure what to tell you that you don't already know.## Sivakumaran Chandrasekaran (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/73659-can-we-able-to-generate-an-image-from-the-given-pixel-values#comment_145816

ok ImageAnalyst. Apart from course instructor, what creative things can be done using MATLAB. I have seen some codings like indian flag, heart beating, man and hen fight... Is there any possibility to develop any handheld electronic game devices, which can use any MATLAB application.. it is not mandatory to install matlab software in that system...

i had a discussion with a programmer who works with google. he works with identification of spam mails. I asked is it possible to use MATLAB to identify spam... I would be happy if you explain this concept.

## Walter Roberson (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/73659-can-we-able-to-generate-an-image-from-the-given-pixel-values#comment_145846

MATLAB is Turing Complete. You can program anything that does not require special hardware.

Some languages are better suited for some tasks than for others.