MKPJ - perceptually improved Jet colormap (Scripts) Publisher's description
from Matteo Niccoli
% MKPJ Returns a perceptually improved Jet colormap
% MKPJ (N,SCHEME) returns an Nx3 colormap.
% usage: map=mkpj(n,scheme);
% JUSTIFICATION: rainbow, or spectrum color schemes are considered a poor
% choice for scientific data display by many in the scientific community
% (see for example reference 1 and 3) in that they introduce artifacts
% that mislead the viewer. "The rainbow color map appears as if itвЂ™s separated
% into bands of almost constant hue, with sharp transitions between hues.
% Viewers perceive these sharp transitions as sharp transitions in the data,
% even when this is not the casein how regularly spaced (interval) data are
% displayed (quoted from reference 1). The default Matlab Jet is no exception.
% Please see examples in my previous FEX submission "Perceptually improved
% This submission is intended to share the results of my work to create a
% more perceptually balanced, Jet colormap. Please see output arguments section
% for more details.
% A full series of posts on improved colormaps will appear on my blog at
% arguments: (input)
% scheme - can be one of the following strings:
% The new, more perceptually balanced, Jet color map.
% This explanation should be read in conjunction with the submitted figure
% The idea to improve the default jet came to me after seeing the human
% wavelenght discrimination curve from Gregory (1964) in the paper by
% Welland et al. (2006).
% The top display in the figure is the standard Matlab Jet. Below it,
% second display, is the Luminance versus wavelenght profile. This is
% essentially the same as plot you would find in the left plot of
% figure 3 in Rogowitz and Kalvin (2001). In the third display I reproduced
% Gregory's curve. It's considering these two together that brought the
% Eureka moment (though it took me a few experiments and some calculations
% to line them up properly). The idea was: "can I use this curve to
% dynamically stretch the rainbow where transitions are too sharp
% (basically around the cyan and yellow), compared to everywhere else?".
% The answer is yes, it can be done. In practice this amounted to calculate
% the "inverted" function in the fourth display. Assuming a distance of 1
% between each of the 256 samples on the x axis in the original Jet colormap,
% the function was used to resample it at non-integer distances (up
% to 1.5 where the yellow is, unmodified at 1 where the cyan is, less
% than 1 everywhere else) resulting in a greater number of samples in
% the yellow area in the display compared to all the blue areas, with
% the total number of samples staying at 256. The next step was to force
% all these new samples back to a distance of 1, achieving a
% continuously dynamic stretch. The resulting colormap is shown in
% the fifth display and accompanied by its Luminance versus wavelenght
% in the last display. This profile is noticeably more perceptually
% balnced with gentler transitions and a compressive character.
% To me this is a very good result, even though it's not perfect.
% In an ideal world I would have paired one of the several human wavelenght
% discrimination curves found in Wyszecki and Stiles (2000)
% with in conjunction with the corresponding spectrum color functions
% (many are referenced in the FEX submission "Spectral and XYZ Color
% Functions"), but the problem I had was to identify a matching pair;
% a problem that in the end proved insurmountable.
% This is the original default Jet which I clipped to lign up with Gregory's curve.
% n - scalar specifying number of points in the colorbar. Maximum n=256
% If n is not specified, the size of the colormap is determined by the
% current figure. If no figure exists, MATLAB creates one.
% arguments: (output)
% map - the output colormap i
% Example: compare cape topography using the improved Jet vs. default Jet(clipped)
% % load cape;
% % imagesc(X); colormap(mkpj(128,'JetI')); colorbar;
% % figure;
% % imagesc(X); colormap(mkpj(128,'J')); colorbar;
See also: JET, HSV, GRAY, HOT, COOL, BONE, COPPER, PINK, FLAG, PRISM,
System Requirements:MATLAB 7.10 (2010a)
Program Release Status: New Release
Program Install Support: Install and Uninstall