Cannot convert images from png to pgm

4 ビュー (過去 30 日間)
Dao Lam
Dao Lam 2015 年 3 月 31 日
コメント済み: Image Analyst 2015 年 3 月 31 日
I'm trying to convert png file to pgm file. I downloaded dragon.png and dragon.ascii.pgm from here
When I ran this code, it shows the image just fine:
oim = pgmRead('dragon.ascii.pgm');
figure;
showIm(oim);
When I try converting from png to pgm using imwrite:
img = imread('dragon.png');
imwrite(img, 'dragon.pgm', 'pgm', 'Encoding', 'ASCII');
oim = pgmRead('dragon.pgm');
figure;
showIm(oim);
The image shows up as some slanted lines. What am I doing wrong? Any help is appreciated.

回答 (1 件)

Image Analyst
Image Analyst 2015 年 3 月 31 日
pgmread() does not appear to be a built-in MATLAB function - at least I don't have it in any of my toolboxes. I suggest you contact the author of pgmread() for guidance.
  2 件のコメント
Dao Lam
Dao Lam 2015 年 3 月 31 日
Is there another way I can convert png to pgm then? Thanks!
My problem is that pgmRead works fine in the 1st case but not the 2nd case when I tried converting.
Image Analyst
Image Analyst 2015 年 3 月 31 日
Why don't you use imread()?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by