Here is an example code snippet in MATLAB to display a gray scale image with three different colormaps using subplot
routine and imshow
function.
main.m458 chars25 lines
The code first reads in an example grayscale image using imread
function. Then, it defines three different colormaps - gray
, hot
and cool
.
Next, a figure with three subplots is created using subplot
routine. In each subplot, the same grayscale image is displayed using imshow
function, but with a different colormap applied using colormap
function. Finally, a title is added to each subplot to indicate the name of the colormap.
This will produce a figure similar to the one shown below.
In this example, subplot
routine is used to create a grid of smaller axes in a figure, which can be used to display multiple plots or images in a single figure window. imshow
function is used to display the grayscale image in each subplot. colormap
function is used to change the color mapping of the image.
gistlibby LogSnag