-
-
Save ccj5351/ae554ea70cef79ab1efdb3f9f92d2b37 to your computer and use it in GitHub Desktop.
Revisions
-
Changjiang_Cai revised this gist
Mar 5, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed. -
ccj5351 revised this gist
Mar 5, 2019 . 3 changed files with 75 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,7 +28,7 @@ def bitget(byteval, idx): return cmap def color_map_viz_1_column(): labels = ['background', 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor', 'void'] nclasses = 21 row_size = 50 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ """ added by CCJ """ def color_map_info(palette): labels = [ 'background', #0 'aeroplane', #1 'bicycle', #2 'bird', #3 'boat', #4 'bottle', #5 'bus', #6 'car', #7 'cat', #8 'chair', #9 'cow', #10 'diningtable', #11 'dog', #12 'horse', #13 'motorbike', #14 'person', #15 'pottedplant', #16 'sheep', #17 'sofa', #18 'train', #19 'tv/monitor', #20 "void/unlabelled", #255 ] print 'class colormap and palette = {r,g,b}' for i in range(0,21*3,3): print '# {:>3d}: {:<20} (R,G,B) = {},{},{}'.format(i/3, labels[i/3], palette[i], palette[i+1],palette[i+2]) i = 255*3 print '# {:>3d}: {:<20} (R,G,B) = {},{},{}'.format(i/3, labels[21], palette[i], palette[i+1],palette[i+2]) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ # added by CCJ: """ arrange these 21 classes to 2D matrix with 3 rows and 7 columns""" def color_map_viz(fname = None): labels = ['B-ground', 'Aero plane', 'Bicycle', 'Bird', 'Boat', 'Bottle', 'Bus', 'Car', 'Cat', 'Chair', 'Cow', 'Dining-Table', 'Dog', 'Horse', 'Motorbike', 'Person', 'Potted-Plant', 'Sheep', 'Sofa', 'Train', 'TV/Monitor', 'Void/Unlabelled'] nclasses = 21 row_size = 80 col_size = 250 cmap = color_map() """ arrange these 21 classes to 2D matrix with 3 rows and 7 columns""" r = 3 c = 7 delta = 10 array = np.empty((row_size*(r+1), col_size*c, cmap.shape[1]), dtype=cmap.dtype) fig=plt.figure() for r_idx in range(0,r): for c_idx in range(0,c): i = r_idx *c + c_idx array[r_idx*row_size:(r_idx+1)*row_size, c_idx*col_size: (c_idx+1)*col_size, :] = cmap[i] x = c_idx*col_size + delta y = r_idx*row_size + row_size/2 s = labels[i] plt.text(x, y,s, fontsize=9, color='white') print "write {} at pixel (r={},c={})".format(labels[i], y,x) array[r*row_size:(r+1)*row_size, :] = cmap[-1] x = 3*col_size + delta y = r*row_size + row_size/2 s = labels[-1] plt.text(x, y,s, fontsize=9, color='black') print "write {} at pixel (r={},c={})".format(labels[i], y,x) plt.title("PASCAL VOC Label Color Map") imshow(array) axis = plt.subplot(1, 1, 1) plt.axis('off') if fname: plt.savefig(fname, dpi=300,bbox_inches='tight', pad_inches=0.1) else: plt.show() -
ccj5351 revised this gist
Mar 5, 2019 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ %Official Matlab version can be found in the PASCAL VOC devkit %http://host.robots.ox.ac.uk/pascal/VOC/voc2012/index.html#devkit % VOCLABELCOLORMAP Creates a label color map such that adjacent indices have different % colors. Useful for reading and writing index images which contain large indices, % by encoding them as RGB images. -
ccj5351 revised this gist
Mar 5, 2019 . 1 changed file with 22 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ % VOCLABELCOLORMAP Creates a label color map such that adjacent indices have different % colors. Useful for reading and writing index images which contain large indices, % by encoding them as RGB images. % % CMAP = VOCLABELCOLORMAP(N) creates a label color map with N entries. function cmap = labelcolormap(N) if nargin==0 N=256 end cmap = zeros(N,3); for i=1:N id = i-1; r=0;g=0;b=0; for j=0:7 r = bitor(r, bitshift(bitget(id,1),7 - j)); g = bitor(g, bitshift(bitget(id,2),7 - j)); b = bitor(b, bitshift(bitget(id,3),7 - j)); id = bitshift(id,-3); end cmap(i,1)=r; cmap(i,2)=g; cmap(i,3)=b; end cmap = cmap / 255; -
wllhf revised this gist
Aug 19, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,7 +29,7 @@ def bitget(byteval, idx): def color_map_viz(): labels = ['background', 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor', 'void'] nclasses = 21 row_size = 50 col_size = 500 -
wllhf revised this gist
May 24, 2016 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,8 +32,9 @@ def color_map_viz(): labels = ['void', 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor', 'border'] nclasses = 21 row_size = 50 col_size = 500 cmap = color_map() array = np.empty((row_size*(nclasses+1), col_size, cmap.shape[1]), dtype=cmap.dtype) for i in range(nclasses): array[i*row_size:i*row_size+row_size, :] = cmap[i] array[nclasses*row_size:nclasses*row_size+row_size, :] = cmap[-1] -
wllhf revised this gist
May 24, 2016 . 1 changed file with 22 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,15 +3,14 @@ Official Matlab version can be found in the PASCAL VOC devkit http://host.robots.ox.ac.uk/pascal/VOC/voc2012/index.html#devkit """ import numpy as np from skimage.io import imshow import matplotlib.pyplot as plt def color_map(N=256, normalized=False): def bitget(byteval, idx): return ((byteval & (1 << idx)) != 0) dtype = 'float32' if normalized else 'uint8' cmap = np.zeros((N, 3), dtype=dtype) for i in range(N): @@ -26,4 +25,20 @@ def color_map(N=256, normalized=False): cmap[i] = np.array([r, g, b]) cmap = cmap/255 if normalized else cmap return cmap def color_map_viz(): labels = ['void', 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor', 'border'] nclasses = 21 row_size = 50 cmap = color_map() array = np.empty((row_size*(nclasses+1), 500, cmap.shape[1]), dtype=cmap.dtype) for i in range(nclasses): array[i*row_size:i*row_size+row_size, :] = cmap[i] array[nclasses*row_size:nclasses*row_size+row_size, :] = cmap[-1] imshow(array) plt.yticks([row_size*i+row_size/2 for i in range(nclasses+1)], labels) plt.xticks([]) plt.show() -
wllhf revised this gist
May 20, 2016 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,9 @@ """ Python implementation of the color map function for the PASCAL VOC data set. Official Matlab version can be found in the PASCAL VOC devkit http://host.robots.ox.ac.uk/pascal/VOC/voc2012/index.html#devkit """ import numpy as np -
wllhf created this gist
May 20, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ import numpy as np def bitget(byteval, idx): return ((byteval & (1 << idx)) != 0) def color_map(N=256, normalized=False): dtype = 'float32' if normalized else 'uint8' cmap = np.zeros((N, 3), dtype=dtype) for i in range(N): r = g = b = 0 c = i for j in range(8): r = r | (bitget(c, 0) << 7-j) g = g | (bitget(c, 1) << 7-j) b = b | (bitget(c, 2) << 7-j) c = c >> 3 cmap[i] = np.array([r, g, b]) cmap = cmap/255 if normalized else cmap return cmap