gokriznastic / HybridSN

A keras based implementation of Hybrid-Spectral-Net as in IEEE GRSL paper "HybridSN: Exploring 3D-2D CNN Feature Hierarchy for Hyperspectral Image Classification".

Home Page:https://ieeexplore.ieee.org/document/8736016

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to show every class map?

Aaron1993 opened this issue · comments

Hi. I want to show every class color map like the picture, how I can do it? Thanks.
image

Hey. I used the following code snippet to do so:

from matplotlib import patches
from spectral import spy_colors

labelDictionary= {0:'Unknown',1:'Alfalfa', 2:'Corn-notill', 3:'Corn-mintill', 4: 'Corn', 5:'Grass-pasture', 6:'Grass-trees', 7:'Grass-pasture-mowed', 8:'Hay-windrowed', 9:'Oats', 10:'Soybean-notill', 11:'Soybean-mintill', 12:'Soybean-clean', 13:'Wheat', 14:'Woods', 15:'Buildings-Grass-Trees-Drives', 16:'Stone-Steel-Towers'}

fig = plt.figure(figsize=(3,3))
ax  = fig.add_subplot(111)
ax.set_position([0.1,0.1,0.5,0.8])

labelPatches = [ patches.Patch(color=spy_colors[x]/255., label=labelDictionary[x]) for x in np.unique(y) ]
leg = ax.legend(handles=labelPatches, ncol=2, loc='center left', bbox_to_anchor=(1.5, 0.5))
fig.savefig('SA_legend.pdf', bbox_extra_artists=(leg,), bbox_inches='tight')