MCPcopy Index your code
hub / github.com/SAMMiCA/ChangeSim / colormap2classmap

Method colormap2classmap

script/utils/Object_Labeling.py:41–49  ·  view source on GitHub ↗
(self,seg_array)

Source from the content-addressed store, hash-verified

39 return classes_idx, classes_str
40
41 def colormap2classmap(self,seg_array):
42 seg_array_flattened = torch.LongTensor(seg_array.reshape(-1,3)).cuda()
43 seg_map_class_flattened = torch.zeros((seg_array.shape[0],seg_array.shape[1],1)).view(-1,1).cuda()
44 for color, cls in self.color2idx.items():
45 matching_indices = (seg_array_flattened == torch.LongTensor(color).cuda())
46 matching_indices = (matching_indices.sum(dim=1)==3)
47 seg_map_class_flattened[matching_indices] = cls
48 seg_map_class = seg_map_class_flattened.view(seg_array.shape[0],seg_array.shape[1],1)
49 return seg_map_class
50
51 def classmap2colormap(self,seg_map_class):
52 seg_map_class_flattened = seg_map_class.view(-1,1)

Callers 2

__getitem__Method · 0.80
callbackMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected