Why is the "print" changing the colors of my plot?

4 次查看(过去 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);

回答(2 个)

Patrick Kalita
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);

Jan
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
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 CenterFile Exchange 中查找有关 Purple 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by