Why is the "print" changing the colors of my plot?
5 ビュー (過去 30 日間)
古いコメントを表示
I have created an axis and I am trying to save the plot as a .jpg automatically. I first tried "saveas" but it was having the same problem. I've tried everything I can think of and this is the latest attempt. The only thing wrong at this point is the .jpg that is saved has different colors. The Blue comes out purple and the red is maroon. Does anyone know how to fix this? Thanks.
set(fig2,'PaperPositionMode', 'auto');
print(fig2, '-djpeg', '-r0', savename);
0 件のコメント
回答 (2 件)
Patrick Kalita
2011 年 7 月 1 日
I think that's just an artifact of the JPEG compression process. JPEG is usually best suited for photographic data where a slight shift in colors isn't as noticeable. You will get more accurate colors if you use a different bitmap format, like PNG:
print(fig2, '-dpng', '-r0', savename);
0 件のコメント
Jan
2011 年 7 月 1 日
Changing a color completely from blue to purple is not a compression artifact. I assume the JPEG is written correctly, but the re-import fails, because it is not written as true-color image and you omit the colormap when using IMREAD. But this is a guess only. Please post an example code, which reproduces the problem including the part of reading the image again.
1 件のコメント
Patrick Kalita
2011 年 7 月 1 日
I'm not sure the original question has anything to do with re-importing. If you just do a simple 'plot(magic(5))' and then follow the poster's 'set' and 'print' statements (changing the figure handles as needed) you can see the color changes by opening the resulting JPEG-file in any image viewer.
参考
カテゴリ
Help Center および File Exchange で Purple についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!