예제 #1
0
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)
예제 #2
0
파일: io_rgb.py 프로젝트: Rbeaty88/ginga
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
예제 #3
0
파일: io_rgb.py 프로젝트: Rbeaty88/ginga
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
예제 #4
0
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
예제 #5
0
    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
예제 #6
0
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)
예제 #7
0
파일: video.py 프로젝트: pmrup/labtools
 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
예제 #8
0
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)
예제 #9
0
def tst_fromimage(filename, irange):
    img = pilutil.fromimage(PIL.Image.open(filename))
    imin,imax = irange
    assert_(img.min() >= imin)
    assert_(img.max() <= imax)
예제 #10
0
def tst_fromimage(filename, irange):
    img = pilutil.fromimage(PIL.Image.open(filename))
    imin, imax = irange
    assert_(img.min() >= imin)
    assert_(img.max() <= imax)
예제 #11
0
파일: format.py 프로젝트: pmrup/labtools
 def open(self, filename):
     return fromimage(PIL_Image.open(filename))