コード例 #1
0
    def _step(self):
        print "[DEBUG] ----- start step"
        # grab image container from port using traits
        in_img_c = self.grab_input_using_trait('image')

        # Get image from conatiner
        in_img = in_img_c.get_image()

        # convert generic image to PIL image
        pil_image = in_img.get_pil_image()

        # draw on the image to prove we can do it
        num = 37
        import ImageDraw
        draw = ImageDraw.Draw(pil_image)
        draw.line((0, 0) + pil_image.size, fill=128, width=5)
        draw.line((0, pil_image.size[1], pil_image.size[0], 0), fill=32768, width=5)
        #                 x0   y0   x1       y1
        draw.rectangle( [num, num, num+100, num+100], outline=125 )
        del draw

        new_image = Image.from_pil( pil_image )  # get new image handle
        new_ic = ImageContainer( new_image )

        # push object to output port
        self.push_to_port_using_trait( 'out_image', new_ic )

        self._base_step()
コード例 #2
0
    def _step(self):
        print "[DEBUG] ----- start step"
        # grab image container from port using traits
        in_img_c = self.grab_input_using_trait('image')

        # Get image from conatiner
        in_img = in_img_c.get_image()

        # convert generic image to PIL image
        pil_image = in_img.get_pil_image()

        # draw on the image to prove we can do it
        num = 37
        import ImageDraw
        draw = ImageDraw.Draw(pil_image)
        draw.line((0, 0) + pil_image.size, fill=128, width=5)
        draw.line((0, pil_image.size[1], pil_image.size[0], 0),
                  fill=32768,
                  width=5)
        #                 x0   y0   x1       y1
        draw.rectangle([num, num, num + 100, num + 100], outline=125)
        del draw

        new_image = Image.from_pil(pil_image)  # get new image handle
        new_ic = ImageContainer(new_image)

        # push object to output port
        self.push_to_port_using_trait('out_image', new_ic)

        self._base_step()
コード例 #3
0
 def test_pil_I(self):
     # test int image
     img = Image(720, 480, 1, True, Image.PIXEL_SIGNED, 4)
     pil_img = img.get_pil_image()
     img2 = Image.from_pil(pil_img)
     nose.tools.assert_equal(img.equal_content(img2), True)
コード例 #4
0
 def test_pil_1(self):
     # test bool image
     img = Image(720, 480, 1, True, Image.PIXEL_BOOL, 1)
     pil_img = img.get_pil_image()
     img2 = Image.from_pil(pil_img)
     nose.tools.assert_equal(img.equal_content(img2), True)
コード例 #5
0
 def test_pil_RGBA(self):
     # test RGBA image
     img = Image(720, 480, 4, True)
     pil_img = img.get_pil_image()
     img2 = Image.from_pil(pil_img)
     nose.tools.assert_equal(img.equal_content(img2), True)