如何在Matlab中保存没有压缩的jpeg图像? [英] How do I save jpeg images with no compression in Matlab?

查看:1789
本文介绍了如何在Matlab中保存没有压缩的jpeg图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Matlab中保存没有压缩的jpeg图像?

How do I save jpeg images with no compression in Matlab?

我试过

targetImageFile = 'skype2.png';
targetImage = imread(targetImageFile);

imwrite(targetImage,'output.png','Compression','none',...
       'WriteMode','append');

然而,我得到了

input:
compressionRatio      = 1.992735e+000
output:
compressionRatio      = 2.090858e+000

感谢您的建议。

推荐答案

目前还不清楚您是否尝试在 JPEG PNG 格式(您的问题和代码示例各使用不同的东西),但如果您查看 IMWRITE 的文档,您会发现这些格式使用'压缩''WriteMode'参数。 TIFF HDF4 格式使用这两个参数。

It's unclear whether you are trying to save your image in JPEG or PNG format (your question and code sample each use something different), but if you look at the documentation for IMWRITE you will notice that neither of those formats uses a 'Compression' or 'WriteMode' parameter. The TIFF and HDF4 formats use those two parameters.

对于 JPEG格式,您可以调整'模式''质量'属性可减少图像压缩。 PNG格式使用无损压缩。如果您想避免所有压缩(有损或无损),您也可以将图像保存为BMP格式。

For JPEG format, you can adjust the 'Mode' or 'Quality' properties to reduce compression of the image. PNG format uses lossless compression. If you want to avoid all compression (lossy or lossless), you may as well just save your image in BMP format.

这是一个保存不同格式图像的几个例子以及输出图像的结果文件大小:

Here are a few examples of saving an image in different formats and the resulting file size of the output image:

X = imread('peppers.png');             %# Sample image: 589,824 bytes of data
imwrite(X,'peppers.bmp');             %# Bitmap output: 589,878 byte output file
imwrite(X,'peppers.png');     %# PNG output (lossless): 287,589 byte output file
imwrite(X,'peppers.jpg');       %# JPEG output (lossy):  23,509 byte output file
imwrite(X,'peppers.jpg',...     %# JPEG output (lossy): 144,068 byte output file
          'Quality',100);
imwrite(X,'peppers.jpg',...  %# JPEG output (lossless): 306,061 byte output file
          'Mode','lossless');

这篇关于如何在Matlab中保存没有压缩的jpeg图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆