更新 2018.12.17
参考我新整理的博客:
深度学习框架Caffe-权值可视化[再次重启]
https://blog.csdn.net/baidu_40840693/article/details/85055520
题外话:
https://zhuanlan.zhihu.com/p/29567314
https://jacobgil.github.io/deeplearning/class-activation-maps
https://github.com/gabrieldemarmiesse/heatmaps
https://github.com/heuritech/convnets-keras
https://github.com/jacobgil/keras-grad-cam
题外话:人流热力图:
https://github.com/bw4sz/heatmap
https://www.youtube.com/watch?v=1-VLHzilz30
第0种
https://github.com/metalbubble/CAM
第一种:
https://github.com/oldj/pyheatmap
第二种
matlab 彩色图和热力图叠加显示
https://blog.csdn.net/liuyifang0810680/article/details/78784102
im = imread('color.jpg'); %彩色图
im = double(im);
gray = imread('gray.jpg'); % 热力图
gray = double(gray);
cmap = colormap(jet(256));
rgb = ind2rgb(gray,cmap);
rgb = rgb * 255;
figure(1);
imshow(uint8(im*0.6+rgb*0.4),[]);
第三种:
Mat aaa = imread("img1.ppm");
Mat gray_img;
cvtColor(aaa, gray_img, COLOR_BGR2GRAY);
Mat heatmap_img;
applyColorMap(gray_img, heatmap_img, COLORMAP_JET);
Mat fin;
addWeighted(heatmap_img, 0.6, aaa, 0.4, 0, fin);
imshow("Depth Map3", heatmap_img);
imshow("Depth Map4", fin);
第四种:
import numpy as np
import cv2
import matplotlib.pyplot as plt
im = cv2.imread("img1.jpg") #读取图片
im_gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY) #转换了灰度化
cv2.imshow('0-gray',im_gray)
cmap = plt.get_cmap('jet')
rgba_img = cmap(im_gray)
rgb_img = np.delete(rgba_img, 3, 2)
cv2.imshow('0-jet',rgb_img)
cv2.waitKey(0)
有一个博客:
https://www.cnblogs.com/arkenstone/p/6932632.html
覆盖效果
以下是我的效果,直接灰度图生成热力图
hsv
gist_rainbow
jet
rainbow
nipy_spectral
"""
==================
Colormap reference
==================
Reference for colormaps included with Matplotlib.
This reference example shows all colormaps included with Matplotlib. Note that
any colormap listed here can be reversed by appending "_r" (e.g., "pink_r").
These colormaps are divided into the following categories:
Sequential:
These colormaps are approximately monochromatic colormaps varying smoothly
between two color tones---usually from low saturation (e.g. white) to high
saturation (e.g. a bright blue). Sequential colormaps are ideal for
representing most scientific data since they show a clear progression from
low-to-high values.
Diverging:
These colormaps have a median value (usually light in color) and vary
smoothly to two different color tones at high and low values. Diverging
colormaps are ideal when your data has a median value that is significant
(e.g. 0, such that positive and negative values are represented by
different colors of the colormap).
Qualitative:
These colormaps vary rapidly in color. Qualitative colormaps are useful for
choosing a set of discrete colors. For example::
color_list = plt.cm.Set3(np.linspace(0, 1, 12))
gives a list of RGB colors that are good for plotting a series of lines on
a dark background.
Miscellaneous:
Colormaps that don't fit into the categories above.
"""
import numpy as np
import matplotlib.pyplot as plt
# Have colormaps separated into categories:
# http://matplotlib.org/examples/color/colormaps_reference.html
cmaps = [('Perceptually Uniform Sequential', [
'viridis', 'plasma', 'inferno', 'magma']),
('Sequential', [
'Greys', 'Purples', 'Blues', 'Greens', 'Oranges', 'Reds',
'YlOrBr', 'YlOrRd', 'OrRd', 'PuRd', 'RdPu', 'BuPu',
'GnBu', 'PuBu', 'YlGnBu', 'PuBuGn', 'BuGn', 'YlGn']),
('Sequential (2)', [
'binary', 'gist_yarg', 'gist_gray', 'gray', 'bone', 'pink',
'spring', 'summer', 'autumn', 'winter', 'cool', 'Wistia',
'hot', 'afmhot', 'gist_heat', 'copper']),
('Diverging', [
'PiYG', 'PRGn', 'BrBG', 'PuOr', 'RdGy', 'RdBu',
'RdYlBu', 'RdYlGn', 'Spectral', 'coolwarm', 'bwr', 'seismic']),
('Qualitative', [
'Pastel1', 'Pastel2', 'Paired', 'Accent',
'Dark2', 'Set1', 'Set2', 'Set3',
'tab10', 'tab20', 'tab20b', 'tab20c']),
('Miscellaneous', [
'flag', 'prism', 'ocean', 'gist_earth', 'terrain', 'gist_stern',
'gnuplot', 'gnuplot2', 'CMRmap', 'cubehelix', 'brg', 'hsv',
'gist_rainbow', 'rainbow', 'jet', 'nipy_spectral', 'gist_ncar'])]
nrows = max(len(cmap_list) for cmap_category, cmap_list in cmaps)
gradient = np.linspace(0, 1, 256)
gradient = np.vstack((gradient, gradient))
def plot_color_gradients(cmap_category, cmap_list, nrows):
fig, axes = plt.subplots(nrows=nrows)
fig.subplots_adjust(top=0.95, bottom=0.01, left=0.2, right=0.99)
axes[0].set_title(cmap_category + ' colormaps', fontsize=14)
for ax, name in zip(axes, cmap_list):
ax.imshow(gradient, aspect='auto', cmap=plt.get_cmap(name))
pos = list(ax.get_position().bounds)
x_text = pos[0] - 0.01
y_text = pos[1] + pos[3]/2.
fig.text(x_text, y_text, name, va='center', ha='right', fontsize=10)
# Turn off *all* ticks & spines, not just the ones with colormaps.
for ax in axes:
ax.set_axis_off()
for cmap_category, cmap_list in cmaps:
plot_color_gradients(cmap_category, cmap_list, nrows)
plt.show()
plot_color_gradients('Miscellaneous', 'hsv',40)