How can I covert serious of grey scale images to jet images

1 visualización (últimos 30 días)
SHILPA S
SHILPA S el 13 de Abr. de 2021
Respondida: Walter Roberson el 13 de Abr. de 2021
I would like to know the coding for coversion of serious of grey scale images to jet color

Respuestas (1)

Walter Roberson
Walter Roberson el 13 de Abr. de 2021
in_ext = '.png';
out_ext = '.png';
projectdir = 'path/to/files'; %can be '.'
outdir = 'path/to/store/output'; %must be different if in_ext and out_ext are the same
if ~exist(outdir, 'dir')
mkdir(outdir);
end
cmap = jet(256);
dinfo = dir(fullfile(projectdir, ['*' in_ext]));
filenames = fullfile({dinfo.folder}, {dinfo.name});
nfiles = length(filenames);
for K = 1 : nfiles
thisfile = filenames{K};
[~, basename, ~] = fileparts(thisfile);
outfile = fullfile(outdir, [basename out_ext]);
if strcmp(thisfile, outfile)
error('Output directory or extension must be different, refuse to overwrite file "%s', thisfile);
end
img = imread(thisfile);
if ndims(img) > 2
warning('skipping file that is already color: %s', thisfile);
continue;
end
imwrite(img, cmap, outfile);
end
fprintf('Done\n');

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by