Clear Filters
Clear Filters

How can i imwrite ppm image file as a ASCII Encoding format

5 views (last 30 days)
After reading the PPM file and processing the data, and save it again using imwrite.
But I cant imwrite ppm image file as a ASCII Encoding format
So I cant properly using that ppm file.
For example,
a = imread("xxxx.ppm")
Iinfo1 = imfinfo('xxxx.ppm')
That file's FormatVersion : 'P3', Formatsignature : 'P3' and Encoding:'ASCII'
but after processing 'a' data, and store parameter 'b'
and Iinfo2 = imfinfo('yyyy.ppm')
That file's FormatVerison : 'P6', Formatsignature : 'P6' and Encoding:'rawbits'
I want imwrite .ppm file as a ASCII Encoding format
please help me.
I can't find any solution on the Internet
I'm sorry for the lack of readability because My English skill are not good
Thanks for reading.

Accepted Answer

Angelo Yeo
Angelo Yeo on 3 Apr 2024
a = imread("sample.ppm");
imwrite(a, "save_sample.ppm","ppm", "Encoding","ASCII")
imginfo = imfinfo("save_sample.ppm")
imginfo =
struct with fields:
Filename: 'C:\Workspace\q2102176\save_sample.ppm'
FileModDate: '03-Apr-2024 15:37:25'
FileSize: 2800776
Format: 'PPM'
FormatVersion: 'P3'
Width: 640
Height: 426
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: 'P3'
Encoding: 'ASCII'
MaxValue: 255
ImageDataOffset: 15

More Answers (0)




Community Treasure Hunt

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

Start Hunting!