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

5 visualizaciones (últimos 30 días)
Matt
Matt el 30 de Jun. de 2011
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);

Respuestas (2)

Patrick Kalita
Patrick Kalita el 1 de Jul. de 2011
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 el 1 de Jul. de 2011
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 comentario
Patrick Kalita
Patrick Kalita el 1 de Jul. de 2011
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Purple en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by