.eps format converts black pixels into white pixels
2 ビュー (過去 30 日間)
古いコメントを表示
Hi everyone,
I would like to save an image generated with imagesc using the ".eps" format, however, the parts of the image that should appear as black are converted into white. This is the code I use: first I generate the image, then I make sure that all NaN values appear as black and finally I save the image as an ".eps" file.
% Generate the image
cmap = parula(256);
colormap(cmap);
imagesc(my_data,'AlphaData', ~isnan(my_data), [50 100]);
set(gca, 'ytick',[], 'xtick',[],'FontSize',14,'Color', [0, 0, 0],'FontName','Times New Roman');
cb = colorbar('southoutside');
% Save the image
saveas(gcf,'my_figure','epsc')
Would you kindly know how to avoid this colour conversion?
Thanks a lot for your help,
Vincenzo
0 件のコメント
回答 (1 件)
Jaswanth
2024 年 4 月 30 日
Hi Vincenzo,
To address the issue of ‘NaN’ values not displaying as black in your ‘.eps’ file outputs, you need to modify the colormap to include black for ‘NaN’values and adjust your data accordingly.
Kindly go through the following approach implementing these modifications:
Extend the Colormap: Add black at the beginning of the parula colormap to represent ‘NaN’values. This ensures ‘NaN’ values have a distinct color.
nanColor = [0, 0, 0]; % Black for NaN
cmap = [nanColor; parula(256)]; % New colormap
colormap(cmap); % Apply it
Adjust Data for NaN Representation: Map ‘NaN’values in your data to the black color in the new colormap. This step ensures ‘NaNs’are visually represented as black.
my_data(isnan(my_data)) = min(my_data(:)) - 1; % NaNs to black
Visualize and Save: Proceed with visualizing your data using imagesc and save the figure as an .eps file. The modified colormap will now accurately display ‘NaN’values as black.
imagesc(my_data, 'AlphaData', ~isnan(my_data), [50 100]); % Visualize data
colormap(cmap); % Apply the modified colormap
% Your existing visualization and saving code here
I hope that the information provided above is helpful in accomplishing your task.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Blue についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!