image - How to add a new colormap on a raster dataset? -
i trying replicate arcgis functionality in matlab, add colormap function. add colormap function in arcgis associates .clr file tiff image image has custom color scheme associated tiff when viewed.
my tiff images have 6 values (1 - 6) in unsigned 8-bit integer format. can see screenshot of images have 1, 2, or 3 values, while others have 6 values--resulting in variable on-screen color rendering.
i see matlab has colormap functionality, however, appears designed figures, rather tiff files. how can associate colormap these tiff images in matlab when view them (e.g. in arcgis), have custom color scheme?
as of commenters have pointed out, colormap
functionality isn't limited figures. colormap concept lookup table maps particular value (index) specific color (in rgb, typically).
if check out documentation imwrite
, see can specify colormap second input function.
load mri im = squeeze(d(:,:,12)); % indexed image (m x n) % save without specifying colormap imwrite(im, 'nocolormap.tif')
now save colormap
imwrite(im, heat, 'colormap.tif')
the other alternative, create rgb image within matlab , save image without providing colormap imwrite
. can either create image manually
% normalize little bit display im = double(im) ./ max(im(:)); output = repmat(im, [1 1 3]); % make image (m x n x 3) imwrite(output, 'rgb_grayscale.tif')
or can use built-in functions gray2rgb
or ind2rgb
convert indexed image rgb image using specific colormap.
rgb_image = gray2rgb(im, jet); imwrite(rgb_image, 'rgb_jet.tif')
one thing pretty important remember in of default, matlab colormap has 64 colors. if need more colors that, can specify when constructing colormap
size(gray) 64 3 size(gray(1000)) 1000 3
this particularly important if you're trying display high fidelity data.
Comments
Post a Comment