Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问预测得到的mask怎么上色? #54

Open
wcl6 opened this issue Nov 11, 2019 · 2 comments
Open

请问预测得到的mask怎么上色? #54

wcl6 opened this issue Nov 11, 2019 · 2 comments

Comments

@wcl6
Copy link

wcl6 commented Nov 11, 2019

预测出来的图像是灰度图,怎么上不同的颜色

@moguiyan
Copy link

同问

@LiNinghui-AI
Copy link

LiNinghui-AI commented Dec 2, 2020

import cv2
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.colors import LinearSegmentedColormap

#在自建的colorabar ,得到自己想要的颜色
def get_spectral():

ALL = 0
VEGETATION = 1
ROAD = 4
BUILDING = 2
WATER = 3
colormap_float = np.zeros( (5, 3), np.float ) #新建一个数组用于存储颜色的数值

colormap_float[ALL, :] = [255, 255, 255]
colormap_float[WATER, :] = [34, 180, 238]
colormap_float[VEGETATION, :] = [159, 255, 84]
colormap_float[BUILDING, :] = [255, 191, 0]
# colormap_float[BUILDING, :] = [34, 180, 238]
colormap_float[ROAD, :] = [38, 71, 139]

return colormap_float

matplotlib.use("Qt5Agg")
path = Satellite-Segmentation-master/segnet/pre1.png"
p_mask = cv2.imread(path)

colormap_float = get_spectral()
rgb_table = LinearSegmentedColormap.from_list('sst cmap', colormap_float/255)

import cmaps
plt.imshow((p_mask[..., 0]), cmap=rgb_table)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants