Lines Matching +full:test +full:. +full:rgb

1 """Test script for the imageop module.  This has the side
2 effect of partially testing the imgfile module as well.
3 Roger E. Masse
6 from test.test_support import verbose, unlink, import_module, run_unittest
19 class InputValidationTests(unittest.TestCase):
38 except (ValueError, imageop.error):
43 self._check(name, size, *extra)
46 self._check(name, None, *extra)
49 self.check_size("crop", 0, 0, 0, 0)
50 self.check_size("scale", 1, 0)
51 self.check_size("scale", -1, -1)
52 self.check_size("tovideo")
53 self.check("grey2mono", 128)
54 self.check("grey2grey4")
55 self.check("grey2grey2")
56 self.check("dither2mono")
57 self.check("dither2grey2")
58 self.check("mono2grey", 0, 0)
59 self.check("grey22grey")
60 self.check("rgb2rgb8") # nlen*4 == len
61 self.check("rgb82rgb")
62 self.check("rgb2grey")
63 self.check("grey2rgb")
65 with self.assertRaises(imageop.error):
66 imageop.grey2rgb('A'*256, 1, 129)
77 # Create binary test files
78 uu.decode(get_qualified_path('testrgb'+os.extsep+'uue'), 'test'+os.extsep+'rgb')
80 image, width, height = getimage('test'+os.extsep+'rgb')
83 # in size and consist of pixels of psize bytes.
86 newimage = imageop.crop (image, 4, width, height, 0, 0, 1, 1)
88 # Return image scaled to size newwidth by newheight. No interpolation
89 # is done, scaling is done by simple-minded pixel duplication or removal.
91 # not look nice after scaling.
94 scaleimage = imageop.scale(image, 4, width, height, 1, 1)
96 # Run a vertical low-pass filter over an image. It does so by computing
98 # pixels. The main use of this routine is to forestall excessive flicker
99 # if the image two vertically-aligned source pixels, hence the name.
102 videoimage = imageop.tovideo (image, 4, width, height)
104 # Convert an rgb image to an 8 bit rgb
107 greyimage = imageop.rgb2rgb8(image, width, height)
109 # Convert an 8 bit rgb image to a 24 bit rgb image
112 image = imageop.rgb82rgb(greyimage, width, height)
114 # Convert an rgb image to an 8 bit greyscale image
117 greyimage = imageop.rgb2grey(image, width, height)
119 # Convert an 8 bit greyscale image to a 24 bit rgb image
122 image = imageop.grey2rgb(greyimage, width, height)
125 # thresholding all the pixels. The resulting image is tightly packed
126 # and is probably only useful as an argument to mono2grey.
129 monoimage = imageop.grey2mono (greyimage, width, height, 0)
131 # monoimage, width, height = getimage('monotest.rgb')
132 # Convert a 1-bit monochrome image to an 8 bit greyscale or color image.
134 # all one-value input pixels get value p1 on output. To convert a
136 # 255 respectively.
139 greyimage = imageop.mono2grey (monoimage, width, height, 0, 255)
142 # (simple-minded) dithering algorithm.
145 monoimage = imageop.dither2mono (greyimage, width, height)
148 # dithering.
151 grey4image = imageop.grey2grey4 (greyimage, width, height)
154 # dithering.
157 grey2image = imageop.grey2grey2 (greyimage, width, height)
160 # dithering. As for dither2mono, the dithering algorithm is currently
161 # very simple.
164 grey2image = imageop.dither2grey2 (greyimage, width, height)
166 # Convert a 4-bit greyscale image to an 8-bit greyscale image.
169 greyimage = imageop.grey42grey (grey4image, width, height)
171 # Convert a 2-bit greyscale image to an 8-bit greyscale image.
174 image = imageop.grey22grey (grey2image, width, height)
177 unlink('test'+os.extsep+'rgb')
185 sizes = imgfile.getsizes(name)
186 except imgfile.error:
188 sizes = imgfile.getsizes(name)
190 print 'imgfile opening test image: %s, sizes: %s' % (name, str(sizes))
192 image = imgfile.read(name)
199 path = sys.path
201 path = [os.path.dirname(__file__)] + path
205 fullname = os.path.join(dir, name)
206 if os.path.exists(fullname):