Python skimage.color() Examples
The following are 12
code examples of skimage.color().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
skimage
, or try the search function
.
Example #1
Source File: utils.py From fcn with MIT License | 6 votes |
def get_label_colortable(n_labels, shape): if cv2 is None: raise RuntimeError('get_label_colortable requires OpenCV (cv2)') rows, cols = shape if rows * cols < n_labels: raise ValueError cmap = label_colormap(n_labels) table = np.zeros((rows * cols, 50, 50, 3), dtype=np.uint8) for lbl_id, color in enumerate(cmap): color_uint8 = (color * 255).astype(np.uint8) table[lbl_id, :, :] = color_uint8 text = '{:<2}'.format(lbl_id) cv2.putText(table[lbl_id], text, (5, 35), cv2.cv.CV_FONT_HERSHEY_SIMPLEX, 0.8, (255, 255, 255), 3) table = table.reshape(rows, cols, 50, 50, 3) table = table.transpose(0, 2, 1, 3, 4) table = table.reshape(rows * 50, cols * 50, 3) return table # ----------------------------------------------------------------------------- # Evaluation # -----------------------------------------------------------------------------
Example #2
Source File: bg_utils.py From SketchySceneColorization with MIT License | 6 votes |
def check_duplicated_color(text): SENTENCE_SPLIT_REGEX = re.compile(r'(\W+)') words = SENTENCE_SPLIT_REGEX.split(text.strip()) words = [w.lower() for w in words if len(w.strip()) > 0] sky_color = '' ground_color = '' for word in words: if word in ALL_COLOR: if sky_color == '': sky_color = word else: ground_color = word break if sky_color == ground_color: raise Exception('It is not recommended to use the same sky and ground color.')
Example #3
Source File: oid_dataset.py From EfficientDet-PyTorch with Apache License 2.0 | 5 votes |
def load_image(self, image_index): path = self.image_path(image_index) img = skimage.io.imread(path) if len(img.shape) == 1: img = img[0] if len(img.shape) == 2: img = skimage.color.gray2rgb(img) try: return img.astype(np.float32) / 255.0 except Exception: print (path) exit(0)
Example #4
Source File: dataloader.py From EfficientDet-PyTorch with Apache License 2.0 | 5 votes |
def load_image(self, image_index): image_info = self.coco.loadImgs(self.image_ids[image_index])[0] path = os.path.join(self.root_dir, 'images', self.set_name, image_info['file_name']) img = skimage.io.imread(path) if len(img.shape) == 2: img = skimage.color.gray2rgb(img) return img.astype(np.float32)/255.0
Example #5
Source File: dataloader.py From EfficientDet-PyTorch with Apache License 2.0 | 5 votes |
def load_image(self, image_index): img = skimage.io.imread(self.image_names[image_index]) if len(img.shape) == 2: img = skimage.color.gray2rgb(img) return img.astype(np.float32)/255.0
Example #6
Source File: agent.py From AIGames with MIT License | 5 votes |
def preprocess(self, image, imagesize): image = skimage.color.rgb2gray(image) image = skimage.transform.resize(image, imagesize, mode='constant') image = skimage.exposure.rescale_intensity(image, out_range=(0, 255)) image = image / 255.0 return image
Example #7
Source File: agent.py From AIGames with MIT License | 5 votes |
def preprocess(self, image, imagesize): image = skimage.color.rgb2gray(image) image = skimage.transform.resize(image, imagesize, mode='constant') image = skimage.exposure.rescale_intensity(image, out_range=(0, 255)) image = image / 255.0 return image
Example #8
Source File: oid_dataset.py From pytorch-retinanet with Apache License 2.0 | 5 votes |
def load_image(self, image_index): path = self.image_path(image_index) img = skimage.io.imread(path) if len(img.shape) == 1: img = img[0] if len(img.shape) == 2: img = skimage.color.gray2rgb(img) try: return img.astype(np.float32) / 255.0 except Exception: print (path) exit(0)
Example #9
Source File: dataloader.py From pytorch-retinanet with Apache License 2.0 | 5 votes |
def load_image(self, image_index): image_info = self.coco.loadImgs(self.image_ids[image_index])[0] path = os.path.join(self.root_dir, 'images', self.set_name, image_info['file_name']) img = skimage.io.imread(path) if len(img.shape) == 2: img = skimage.color.gray2rgb(img) return img.astype(np.float32)/255.0
Example #10
Source File: dataloader.py From pytorch-retinanet with Apache License 2.0 | 5 votes |
def load_image(self, image_index): img = skimage.io.imread(self.image_names[image_index]) if len(img.shape) == 2: img = skimage.color.gray2rgb(img) return img.astype(np.float32)/255.0
Example #11
Source File: formsboxdetect_printer.py From Visual-Template-Free-Form-Parsing with GNU General Public License v3.0 | 5 votes |
def plotRect(img,color,xyrhw,lineW=1): tl,tr,br,bl = getCorners(xyrhw) cv2.line(img,tl,tr,color,lineW) cv2.line(img,tr,br,color,lineW) cv2.line(img,br,bl,color,lineW) cv2.line(img,bl,tl,color,lineW)
Example #12
Source File: dataset_mastcam.py From DEMUD with Apache License 2.0 | 5 votes |
def collapse_RGB(self, image, name): if len(image.shape) == 3: if image.shape[2] == 1: #print " this image (%s)\n is only one channel as of reaching process_image" % name pass elif image.shape[2] == 3: #image = image.astype('uint8') #img_show = PIL.Image.fromarray(image[...,0]) #img_show.save('./mastcam_images/%s_bandR.png' % name) #img_show = PIL.Image.fromarray(image[...,1]) #img_show.save('./mastcam_images/%s_bandG.png' % name) #img_show = PIL.Image.fromarray(image[...,2]) #img_show.save('./mastcam_images/%s_bandB.png' % name) image = image.astype('uint16') image = image[...,0] + image[...,1] + image[...,2] image = image / 3 image = image.astype('uint8') #img_show = PIL.Image.fromarray(image) #img_show.save('./mastcam_images/%s_rgb.png' % name) elif image.shape[2] == 7: image = image.astype('uint16') image = image[...,0] + image[...,1] + image[...,2] + image[...,3] + image[...,4] + image[...,5] + image[...,6] image = image / 7 image = image.astype('uint8') else: print "This image has %d color bands and that's weird." % image.shape[2] exit() elif len(image.shape) == 2: print "This image has only one channel!" pass else: print "This image has %d dimensions and that's weird." % len(image.shape) exit() return image #_______________________________________________________________________________ #_______________________________________main____________________________________ #