problem exporting figure to a single channel

after exporting the plotted figure to figure-01.png, the ,file dimenstion si already in 3 channels.
the code:
exportgraphics(figure(1),sprintf('fig_%02d.png', i),'Colorspace', 'gray')
A = imread("fig_01.png")
As result, the dimention of A = [h w 3]

1 Kommentar

Catalytic
Catalytic am 6 Mär. 2026
You have abandoned your last 4 posts -
Please do not do this. Click the 'accept' button on answers that resolve your question, or respond to the contributors to say why their answers do not.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Stephen23
Stephen23 am 6 Mär. 2026
plot(rand(7,3))
F = getframe(figure(1));
I = im2gray(F.cdata);
imwrite(I,'test.png')
size(I)
ans = 1×2
420 561
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
clearvars
J = imread('test.png');
size(J)
ans = 1×2
420 561
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>

Produkte

Version

R2024a

Gefragt:

am 6 Mär. 2026

Kommentiert:

am 6 Mär. 2026

Community Treasure Hunt

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

Start Hunting!

Translated by