用matlab保存图像文件,Matlab保存workspace中的图像数据为jpg文件

由于不小心疏忽,把imread()的图像文件给重写了:

s = sprintf('%s.txt',I);%I是图像文件名 如I=1.jpg

dlmwrite(s,p)

dlmwrite

Write matrix to ASCII-delimited file

Syntax

dlmwrite(filename, M)

dlmwrite(filename, M, 'D')

dlmwrite(filename, M, 'D', R, C)

dlmwrite(filename, M, 'attrib1', value1, 'attrib2', value2, ...)

dlmwrite(filename, M, '-append')

dlmwrite(filename, M, '-append', attribute-value list)

Description

dlmwrite(filename, M)writes matrix M into an ASCII format file using the default delimiter (,) to separate matrix elements. The data is written starting at the first column of the first row in the destination file, filename. The filename input is a string enclosed in single quotes.

dlmwrite(filename, M, ‘D’) writes matrix M into an ASCII format file, using delimiter D to separate matrix elements. The data is written starting at the first column of the first row in the destination file, filename. A comma (,) is the default delimiter. Use \t to produce tab-delimited files.

于是采取补救措施imwrite输出图像:

imwriteWrite image to graphics file

Syntax

imwrite(A,filename,fmt)

imwrite(X,map,filename,fmt)

imwrite(...,filename)

imwrite(...,Param1,Val1,Param2,Val2...)

Description

imwrite(A,filename,fmt) writes the image A to the file specified by filename in the format specified by fmt.

A can be an M-by-N (grayscale image) or M-by-N-by-3 (truecolor image) array, but it cannot be an empty array. For TIFF files, A can be an M-by-N-by-4 array containing color data that uses the CMYK color space. For GIF files, A can be an M-by-N-by-1-by-P array containing grayscale or indexed images — RGB images are not supported. For information about the class of the input array and the output image, see Class Support.

filename is a string that specifies the name of the output file.

fmt can be any of the text strings listed in the table in Supported Image Types. This list of supported formats is determined by the MATLAB image file format registry. See imformats for more information about this registry.

imwrite(X,map,filename,fmt) writes the indexed image in X and its associated colormap map to filename in the format specified by fmt. If X is of class uint8 or uint16, imwrite writes the actual values in the array to the file. If X is of class double, imwrite offsets the values in the array before writing, using uint8(X–1). map must be a valid MATLAB colormap. Note that most image file formats do not support colormaps with more than 256 entries.

When writing multiframe GIF images, X should be an 4-dimensional M-by-N-by-1-by-P array, where P is the number of frames to write.

imwrite(…,filename) writes the image to filename, inferring the format to use from the filename’s extension. The extension must be one of the values for fmt, listed in Supported Image Types.

imwrite(…,Param1,Val1,Param2,Val2…) specifies parameters that control various characteristics of the output file for HDF, JPEG, PBM, PGM, PNG, PPM, and TIFF files. For example, if you are writing a JPEG file, you can specify the quality of the output image. For the lists of parameters available for each format.

In short:

imwrite(A,FILENAME,FMT) 把图像 A 写入图像文件 FILENAME.

imwrite(X,MAP,FILENAME,FMT) 把 X和它的相关色彩信息MAP写入FILENAME.

imwrite(…,FILENAME) 把图像写入图像文件FILENAME,并推测可能的格式用来做filename的扩展名。扩展名必须是FMT中一合法名.

imwrite(…,PARAM1,VAL1,PARAM2,VAL2,…) 不同的参数控制输出文件的各种不同特征。参数要是当前所支持的HDF,JPEG, TIFF, PNG, PBM, PGM, 和PPM 文件

所以我用:

>> imwrite(im,'1','.jpg')

Like this:

Like Loading...

Related

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值