www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/LoadAndDisplayJPEGImageFileExample.m

    %% Load and Display JPEG Image File
% Load a JPEG image file of the Cat's Eye Nebula from the Hubble Space
% Telescope (image courtesy NASA). Display the original image using its RGB
% color values (left) as a subplot.
%
% Create a linked subplot (same size and scale) to display the transformed
% intensity image as a heat map (right).

% Copyright 2015 The MathWorks, Inc.



figure
ax(1) = subplot(1,2,1);
rgb = imread('ngc6543a.jpg');
image(rgb)
title('RGB image')

ax(2) = subplot(1,2,2);
im = mean(rgb,3);
image(im)
title('Intensity Heat Map')
colormap(hot(256))
linkaxes(ax,'xy')
axis(ax,'image')