How I can save Image without using imwrite ?

I want a code that save Image after I construct this Image from blocks,I used imwrite but it effect on the values of the Image when I read this Image ,please I need your help in that problem ????

2 Kommentare

Could you please also state what kind of effect of imwrite is the problem?
Ameligege
Ameligege am 7 Mai 2015
Bearbeitet: Walter Roberson am 8 Mai 2015
I wrote the result in notebad file after imwrite
when I read it from another function to read the result Image and write it to notebad file ,these notbad files are different
here is the some values first row of the result Image
52,59,58,66,66,61,67,68,66,65,63,62,62,62,60
here is the first row from where I read the result Image
65,63,66,75,62,53,67,71,67,66,65,64,62,61,59,59,64,63,60

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 7 Mai 2015

1 Stimme

Save it to a .mat file with save().

13 Kommentare

Ameligege
Ameligege am 7 Mai 2015
can I display the image If I save it as .mat
Joseph Cheng
Joseph Cheng am 7 Mai 2015
Bearbeitet: Joseph Cheng am 7 Mai 2015
depends... are you looking to view it in another program as in you're still trying to save it as a jpg, png, or tiff then NO? OR if you just want the RAW data then the .mat will be able to be loaded back into matlab. Otherwise if you could always just use fwrite and save it as a RAW file.
Ameligege
Ameligege am 7 Mai 2015
no, I want it as jpg the result must be jpg is there any way to convert this matrix to jpg Image ??
Ameligege
Ameligege am 7 Mai 2015
these text files Iam just using it to check the values but I need the jpg Image withe precise values any suggestion please?
Joseph Cheng
Joseph Cheng am 7 Mai 2015
Bearbeitet: Joseph Cheng am 7 Mai 2015
well you're dealing with jpg compression which is terrible if you're looking to get your exact values back and using the default parameters. Unless you are using lossless compression. you can try setting different modes in the jpeg section to get lossless compression.
Guillaume
Guillaume am 7 Mai 2015
@Joseph, standard jpg does not support lossless compression (*unless you don't use the standard jpeg library). jpeg 2000 does, but usually use a different extension (.jp2).
@Ameligege, before complaining that imwrite does not give you the result you expect when you use a particular file format, it would be a good idea to learn about the capabilities of the file format. jpg is a lossy compression format, you never get back the same value you wrote. Use png, bmp, tiff with a different compression than jpeg obviously) or other lossless format.
Each format also has some limitation over the range of intensities they can encode (8-bit, 16-bit, etc.) and number of channels (1,3, 4).
Walter Roberson
Walter Roberson am 7 Mai 2015
imwrite will do lossless jpeg though, and it is not uncommon for it to be supported by other programs
Image Analyst
Image Analyst am 7 Mai 2015
You can get back the image variable from .mat and display it with imshow(). imshow() doesn't really care what format the image was when it was on disk. Compressed, uncompressed, integer, floating point - it just doesn't care (as long as you pass it the variable instead of a filename string). It's the job of the reader function to read it in and give you a proper MATLAB variable, and that's all imshow() cares about.
Mat files are a proprietary format though. If you want to see thumbnails in your Windows Explorer or be able to read it with other programs, like Photoshop, then you should store it in a standard format, perhaps one that can handle floating point numbers or whatever strange stuff you had that didn't let imwrite store it properly.
Image Analyst
Image Analyst am 7 Mai 2015
Ameligege, I recommend you use PNG format with imwrite. That's what I always use and it's pretty much become a standard for much/most of the digital imaging world. You can make a round trip from variable to disk to variable with PNG and there will be no change of values because it's an lossless, compressed format.
Hello, I have png image with pixel value 0 and 255. I am trying to save this as same png format after changing the value to 0=1 and 255=2 using "imwrite". But, unfortunately it save the image with all value as 255.
NewImage = uint8(YourImage + 1) ;
NewImage(YourImage > 1) = 2;
Thank you Walter, it works....:)
Image Analyst
Image Analyst am 6 Jan. 2017
Why do you want 1 and 2 instead of the more usual 0 and 1 (used for binary images, masks, ROIs, etc.)?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Images finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 7 Mai 2015

Kommentiert:

am 6 Jan. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by