def tst_fromimage(filename, irange): fp = open(filename, "rb") img = pilutil.fromimage(PIL.Image.open(fp)) fp.close() imin,imax = irange assert_(img.min() >= imin) assert_(img.max() <= imax)
def convert_profile_numpy_transform(image_np, transform): if (not have_pilutil) or (not have_cms): return image_np in_image_pil = pilutil.toimage(image_np) convert_profile_pil_transform(in_image_pil, transform, inPlace=True) image_out = pilutil.fromimage(in_image_pil) return image_out
def convert_profile_numpy(image_np, inprof_path, outprof_path): if (not have_pilutil) or (not have_cms): return image_np in_image_pil = pilutil.toimage(image_np) out_image_pil = convert_profile_pil(in_image_pil, inprof_path, outprof_path) image_out = pilutil.fromimage(out_image_pil) return image_out
def convert_profile_numpy(image_np, inprof_path, outprof_path): if not have_pilutil: return image_np in_image_pil = pilutil.toimage(image_np) out_image_pil = pilutil.convert_profile_pil(in_image_pil, inprof_path, outprof_path) image_np = pilutil.fromimage(out_image_pil) return image_out
def test_fromimage(self): data = {'icon.png':(0,255), 'icon_mono.png':(0,2), 'icon_mono_flat.png':(0,1)} for fn,irange in data.iteritems(): img = pilutil.fromimage(PIL.Image.open(os.path.join(datapath,fn))) imin,imax = irange assert img.min() >= imin assert img.max() <= imax
def read_jpg(file_path): image = Image.open(file_path) if hasattr(image, "_getexif"): orientation = 0x0112 exif = image._getexif() if exif is not None: orientation = exif[orientation] rotations = { 3: Image.ROTATE_180, 6: Image.ROTATE_270, 8: Image.ROTATE_90 } if orientation in rotations: image = image.transpose(rotations[orientation]) return fromimage(image, flatten=False, mode=None)
def get_frame(self, index): """Opens frame and returns image storred in numpy array :param index: specifies frame index :returns numpy.array of a given frame """ if self.video_type == 'pixelink': self.image = self.stream.get_frame(index) self.figure.update_image(self.image) else: self.image = fromimage(self.stream.GetFrameNo(index)) self.figure.update_image(self.image[:, :, 0]) return self.image
def read_jpg(file_path): image = Image.open(file_path) if hasattr(image, '_getexif'): orientation = 0x0112 exif = image._getexif() if exif is not None: orientation = exif[orientation] rotations = { 3: Image.ROTATE_180, 6: Image.ROTATE_270, 8: Image.ROTATE_90 } if orientation in rotations: image = image.transpose(rotations[orientation]) img = fromimage(image, flatten=False, mode=None) # convert to gray-scale image img = img.mean(axis=2) return np.asarray(img, dtype=np.float32)
def tst_fromimage(filename, irange): img = pilutil.fromimage(PIL.Image.open(filename)) imin,imax = irange assert_(img.min() >= imin) assert_(img.max() <= imax)
def tst_fromimage(filename, irange): img = pilutil.fromimage(PIL.Image.open(filename)) imin, imax = irange assert_(img.min() >= imin) assert_(img.max() <= imax)
def open(self, filename): return fromimage(PIL_Image.open(filename))