'jet' countour plot over grayscale image

4 ビュー (過去 30 日間)
Eric
Eric 2012 年 6 月 13 日
回答済み: DGM 2022 年 4 月 22 日
How do I plot a grayscale image with a contourmap over it. The contourmap should have the 'jet' colormap. Simply adding cmap = [jet(32); gray(32)]; makes the contourmap gray. I have tried the methods mentioned in http://www.mathworks.se/support/solutions/en/data/1-GNRWEH/index.html, but none seem to be able to make the grayscale image only grayscale and the contourmap only jet.

採用された回答

Walter Roberson
Walter Roberson 2012 年 6 月 13 日
I suggest you use the File Exchange contribution "freezeColors" on the grayscale image.

その他の回答 (2 件)

DGM
DGM 2022 年 4 月 22 日
This is easier than everyone is making it. You can avoid the necessity for two colormaps by simply expanding the single-channel grayscale image such that it has three channels. At that point, image/imagesc/imshow will no longer try to represent it as a colormapped image, and you'll be free to use the axes colormap for the overlaid contour/surf/whatever object.
I answered a similar question requiring a semitransparent contourf plot overlaid on a grayscale image here:
But what if I actually want my grayscale base image to be represented in pseudocolor using some colormap other than gray()? Maybe you want your single-channel image represented with parula(), but you want the overlay to use jet(). That's only a minor complication. Instead of expanding the single-channel image by replication, expand it using ind2rgb() and the desired colormap. In either case, the end result is that the base image is RGB, so its display will be independent of the axes colormap.

Eric
Eric 2012 年 6 月 13 日
I might have been too fast with the acceptance. The contour plot is plotted in color over the grayscale image, but does not use the entire colormap. I tried using the 'jet' colormap for the contour map and it only used the dark-blue to red colors. If I plot the same contour map without the grayscale image the entire 'jet' colormap is used. This is probably something I can edit by taking a closer look at freezeColors...

カテゴリ

Help Center および File ExchangeRed についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by