MATLAB: How to save the output image

imagessave as

citra=imread('ISIC_0024336.jpg');
figure, fig1=imshow(citra);
load mri
V = squeeze(citra);
citra3=montage(reshape(V,size(citra)),map,'Indices',3);
saveas(citra3,'ISIC_0024336coba.jpg');
Would you help me please, How to save the output image in Matlab automatically?

Best Answer

infile = 'ISIC_0024336.jpg';
citra=imread(infile);
figure, fig1=imshow(citra);
load mri
V = squeeze(citra);
citra3=montage(reshape(V,size(citra)),map,'Indices',3);
[folder, basename, ext] = fileparts(infile);
outfile = fullfile(folder, [basename 'coba' ext]);
saveas(citra3, outfile);