how save image in jpeg format by keeping pixel value?

조회 수: 6 (최근 30일)
Jack Moriss
Jack Moriss 2016년 6월 21일
댓글: sb icse 2018년 11월 23일
i have an rgb image in double format and i want to save it as jpeg so i convert it to uint8 and use imwrite to save it but it changes pixel value . how can i save it by keeping values beacuse i need former values?
  댓글 수: 1
sb icse
sb icse 2018년 11월 23일
Have you found out the solution to your question?If yes then can you share the code and thank you in advance.

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

답변 (2개)

Walter Roberson
Walter Roberson 2016년 6월 21일
imwrite(YourImage, 'YourFile.jpg', 'mode', 'lossless')
This will use the seldom-used JPEG lossless compression.
I would advise that unless you have a strict requirement to use JPEG that instead you use one of the lossless image formats such as PNG or TIFF. When you use JPEG, it is all too likely that at some point someone (you) will forget (or not know) that it is important that the pixels remain unchanged when read back in.
Note: if you are trying to do watermarking or steganography, then you should pretty much assume that the image will be converted to lossy JPEG at some point, and you need the information to survive even so. One of the several ways to handle that is to do your own DCT, embed the information in the DCT coefficients, and do an inverse DCT and imwrite() that. Then when the JPEG library does its DCT, the result it is going to end up with will be the result that holds the embedded information. For recovery afterwards, DCT the loaded image and extract the bits.
  댓글 수: 7
Doanh Ho
Doanh Ho 2018년 7월 13일
Thank you Walter, I want to embed bits to the DC Coefficient. I do dct() on R value, quantize the dctmaxtrix, modifiy the DC coefficient to embed a bit and then do an inverse dct to get back the new R value. Then I save the image with new R value.
image.save(output_file, format='JPEG', subsampling=0, quality=95)
After saving jpeg, it compresses and when I read the image back, I cannot got the new R value. I think I'm wrong when I do image.save() by this way. Because it compressed the image one more time and change RGB value. Could you pleased give me some guides to get the right value after idct() and get the new R value. How to save the new R value? Thank you so much.
Walter Roberson
Walter Roberson 2018년 7월 13일
image.save(output_file, format='JPEG', subsampling=0, quality=95)
is not MATLAB code.

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


Muhammad Usman Saleem
Muhammad Usman Saleem 2016년 6월 21일
try this
save('myimage.gpeg','originalImage');
  댓글 수: 1
Walter Roberson
Walter Roberson 2016년 6월 21일
편집: Walter Roberson 2016년 6월 21일
That would result in something that was in .mat file format but with a .gpeg file extension, and which would not be readable by any image viewer.

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

카테고리

Help CenterFile Exchange에서 Denoising and Compression에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by