由于不小心疏忽,把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