Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: tools/telemetry/telemetry/core/bitmap_unittest.py

Issue 668753002: [Telemetry] Migrate bitmap.py from bitmaptools.cc to numpy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make GetBoundingBox just, like, WAY too fast Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from __future__ import division
6
7 import cv2
5 import os 8 import os
6 import tempfile 9 import tempfile
7 import unittest 10 import unittest
8 11
9 from telemetry import benchmark
10 from telemetry.core import bitmap 12 from telemetry.core import bitmap
11 from telemetry.core import util 13 from telemetry.core import util
12 14
13 # This is a simple base64 encoded 2x2 PNG which contains, in order, a single 15 # This is a simple base64 encoded 2x2 PNG which contains, in order, a single
14 # Red, Yellow, Blue, and Green pixel. 16 # Red, Yellow, Blue, and Green pixel.
15 test_png = """ 17 test_png = """
16 iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91 18 iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91
17 JpzAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACx 19 JpzAAAAFklEQVR4Xg3EAQ0AAABAMP1LY3YI7l8l6A
18 MBAJqcGAAAABZJREFUCNdj/M/AwPCfgYGB4T/DfwY 20 T8tgwbJAAAAABJRU5ErkJggg==
19 AHAAD/iOWZXsAAAAASUVORK5CYII=
20 """ 21 """
22
21 test_png_path = os.path.join(util.GetUnittestDataDir(), 'test_png.png') 23 test_png_path = os.path.join(util.GetUnittestDataDir(), 'test_png.png')
22 test_png_2_path = os.path.join(util.GetUnittestDataDir(), 'test_png_2.png') 24 test_png_2_path = os.path.join(util.GetUnittestDataDir(), 'test_png_2.png')
23 25
24 26
25 class HistogramDistanceTest(unittest.TestCase): 27 class HistogramDistanceTest(unittest.TestCase):
28
26 def testNoData(self): 29 def testNoData(self):
27 hist1 = [] 30 hist1 = []
28 hist2 = [] 31 hist2 = []
29 self.assertRaises( 32 self.assertRaises(
30 ValueError, lambda: bitmap.HistogramDistance(hist1, hist2)) 33 ValueError, lambda: bitmap.HistogramDistance(hist1, hist2))
31 34
32 hist1 = [0, 0, 0] 35 hist1 = [0, 0, 0]
33 hist2 = [0, 0, 0] 36 hist2 = [0, 0, 0]
34 self.assertRaises( 37 self.assertRaises(
35 ValueError, lambda: bitmap.HistogramDistance(hist1, hist2)) 38 ValueError, lambda: bitmap.HistogramDistance(hist1, hist2))
36 39
37 def testWrongSizes(self): 40 def testWrongSizes(self):
38 hist1 = [1] 41 hist1 = [1]
39 hist2 = [1, 0] 42 hist2 = [1, 0]
40 self.assertRaises( 43 self.assertRaises(
41 ValueError, lambda: bitmap.HistogramDistance(hist1, hist2)) 44 ValueError, lambda: bitmap.HistogramDistance(hist1, hist2))
42 45
43 def testNoDistance(self): 46 def testNoDistance(self):
44 hist1 = [2, 4, 1, 8, 0, -1] 47 hist1 = [2, 4, 1, 8, 0, 0]
45 hist2 = [2, 4, 1, 8, 0, -1] 48 hist2 = [2, 4, 1, 8, 0, 0]
46 self.assertEqual(bitmap.HistogramDistance(hist1, hist2), 0) 49 self.assertEqual(bitmap.HistogramDistance(hist1, hist2), 0)
47 50
48 def testNormalizeCounts(self): 51 def testNormalizeCounts(self):
49 hist1 = [0, 0, 1, 0, 0] 52 hist1 = [0, 0, 1, 0, 0]
50 hist2 = [0, 0, 0, 0, 7] 53 hist2 = [0, 0, 0, 0, 7]
51 self.assertEqual(bitmap.HistogramDistance(hist1, hist2), 2) 54 self.assertAlmostEqual(bitmap.HistogramDistance(hist1, hist2), 2)
52 self.assertEqual(bitmap.HistogramDistance(hist2, hist1), 2) 55 self.assertAlmostEqual(bitmap.HistogramDistance(hist2, hist1), 2)
53 56
54 def testDistance(self): 57 def testDistance(self):
55 hist1 = [2, 0, 1, 3, 4] 58 hist1 = [2, 0, 1, 3, 4]
56 hist2 = [3, 1, 2, 4, 0] 59 hist2 = [3, 1, 2, 4, 0]
57 self.assertEqual(bitmap.HistogramDistance(hist1, hist2), 1) 60 self.assertEqual(bitmap.HistogramDistance(hist1, hist2), 1)
58 self.assertEqual(bitmap.HistogramDistance(hist2, hist1), 1) 61 self.assertEqual(bitmap.HistogramDistance(hist2, hist1), 1)
59 62
60 hist1 = [0, 1, 3, 1] 63 hist1 = [0, 1, 3, 1]
61 hist2 = [2, 2, 1, 0] 64 hist2 = [2, 2, 1, 0]
62 self.assertEqual(bitmap.HistogramDistance(hist1, hist2), 1.2) 65 self.assertAlmostEqual(bitmap.HistogramDistance(hist1, hist2), 1.2)
63 self.assertEqual(bitmap.HistogramDistance(hist2, hist1), 1.2) 66 self.assertAlmostEqual(bitmap.HistogramDistance(hist2, hist1), 1.2)
64 67
65 68
66 class BitmapTest(unittest.TestCase): 69 class BitmapTest(unittest.TestCase):
67 70
68 # pylint: disable=C0324 71 def testRGBAColorAsInt(self):
72 self.assertEqual(bitmap.BGRAColorAsInt((254, 255, 255, 255)), (1 << 32) - 2)
73 self.assertEqual(bitmap.BGRAColorAsInt((255, 254, 255, 255)),
74 (1 << 32) - (1 << 8) - 1)
75 self.assertEqual(bitmap.BGRAColorAsInt((255, 255, 254, 255)),
76 (1 << 32) - (1 << 16) - 1)
77 self.assertEqual(bitmap.BGRAColorAsInt((255, 255, 255, 254)),
78 (1 << 32) - (1 << 24) - 1)
69 79
70 def testReadFromBase64Png(self): 80 def testReadFromBase64Png(self):
71 bmp = bitmap.Bitmap.FromBase64Png(test_png) 81 bmp = bitmap.Bitmap.FromBase64Png(test_png)
72 82
73 self.assertEquals(2, bmp.width) 83 self.assertEquals(2, bmp.width)
74 self.assertEquals(2, bmp.height) 84 self.assertEquals(2, bmp.height)
75 85
76 bmp.GetPixelColor(0, 0).AssertIsRGB(255, 0, 0) 86 self.assertTrue(bitmap.ColorsAreEqual(bmp.image[0][0], (0, 0, 255)))
77 bmp.GetPixelColor(1, 1).AssertIsRGB(0, 255, 0) 87 self.assertTrue(bitmap.ColorsAreEqual(bmp.image[1][1], (0, 255, 0)))
78 bmp.GetPixelColor(0, 1).AssertIsRGB(0, 0, 255) 88 self.assertTrue(bitmap.ColorsAreEqual(bmp.image[1][0], (255, 0, 0)))
79 bmp.GetPixelColor(1, 0).AssertIsRGB(255, 255, 0) 89 self.assertTrue(bitmap.ColorsAreEqual(bmp.image[0][1], (0, 255, 255)))
80 90
81 def testReadFromPngFile(self): 91 def testReadFromPngFile(self):
82 file_bmp = bitmap.Bitmap.FromPngFile(test_png_path) 92 file_bmp = bitmap.Bitmap.FromImageFile(test_png_path)
83 93
84 self.assertEquals(2, file_bmp.width) 94 self.assertEquals(2, file_bmp.width)
85 self.assertEquals(2, file_bmp.height) 95 self.assertEquals(2, file_bmp.height)
86 96
87 file_bmp.GetPixelColor(0, 0).AssertIsRGB(255, 0, 0) 97 self.assertTrue(bitmap.ColorsAreEqual(file_bmp.image[0][0], (0, 0, 255)))
88 file_bmp.GetPixelColor(1, 1).AssertIsRGB(0, 255, 0) 98 self.assertTrue(bitmap.ColorsAreEqual(file_bmp.image[1][1], (0, 255, 0)))
89 file_bmp.GetPixelColor(0, 1).AssertIsRGB(0, 0, 255) 99 self.assertTrue(bitmap.ColorsAreEqual(file_bmp.image[1][0], (255, 0, 0)))
90 file_bmp.GetPixelColor(1, 0).AssertIsRGB(255, 255, 0) 100 self.assertTrue(bitmap.ColorsAreEqual(file_bmp.image[0][1], (0, 255, 255)))
91 101
92 def testWritePngToPngFile(self): 102 def testWritePngToPngFile(self):
93 orig = bitmap.Bitmap.FromPngFile(test_png_path) 103 orig = bitmap.Bitmap.FromImageFile(test_png_path)
94 temp_file = tempfile.NamedTemporaryFile().name 104 temp_file = tempfile.NamedTemporaryFile(suffix='.png').name
95 orig.WritePngFile(temp_file) 105 cv2.imwrite(temp_file, orig.image)
96 new_file = bitmap.Bitmap.FromPngFile(temp_file) 106 new_file = bitmap.Bitmap.FromImageFile(temp_file)
97 self.assertTrue(orig.IsEqual(new_file)) 107 self.assertTrue(orig.IsEqual(new_file))
98 108
99 @benchmark.Disabled
100 def testWriteCroppedBmpToPngFile(self): 109 def testWriteCroppedBmpToPngFile(self):
101 pixels = [255,0,0, 255,255,0, 0,0,0, 110 pixels = [255,0,0, 255,255,0, 0,0,0,
102 255,255,0, 0,255,0, 0,0,0] 111 255,255,0, 0,255,0, 0,0,0]
103 orig = bitmap.Bitmap(3, 3, 2, pixels) 112 orig = bitmap.Bitmap.FromRGBPixels(3, 2, pixels, 3)
104 orig.Crop(0, 0, 2, 2) 113 orig.Crop(0, 0, 2, 2)
105 temp_file = tempfile.NamedTemporaryFile().name 114 temp_file = tempfile.NamedTemporaryFile(suffix='.png').name
106 orig.WritePngFile(temp_file) 115 cv2.imwrite(temp_file, orig.image)
107 new_file = bitmap.Bitmap.FromPngFile(temp_file) 116 new_file = bitmap.Bitmap.FromImageFile(temp_file)
108 self.assertTrue(orig.IsEqual(new_file)) 117 self.assertTrue(orig.IsEqual(new_file))
109 118
110 def testIsEqual(self): 119 def testDiff(self):
111 bmp = bitmap.Bitmap.FromBase64Png(test_png) 120 file_bmp = bitmap.Bitmap.FromImageFile(test_png_path)
112 file_bmp = bitmap.Bitmap.FromPngFile(test_png_path) 121 file_bmp_2 = bitmap.Bitmap.FromImageFile(test_png_2_path)
113 self.assertTrue(bmp.IsEqual(file_bmp))
114 122
115 def testDiff(self): 123 diff = file_bmp.Diff(file_bmp)
116 file_bmp = bitmap.Bitmap.FromPngFile(test_png_path)
117 file_bmp_2 = bitmap.Bitmap.FromPngFile(test_png_2_path)
118 124
119 diff_bmp = file_bmp.Diff(file_bmp) 125 self.assertEquals(2, diff.width)
126 self.assertEquals(2, diff.height)
120 127
121 self.assertEquals(2, diff_bmp.width) 128 self.assertTrue(bitmap.ColorsAreEqual(diff.image[0][0], (0, 0, 0)))
122 self.assertEquals(2, diff_bmp.height) 129 self.assertTrue(bitmap.ColorsAreEqual(diff.image[1][1], (0, 0, 0)))
130 self.assertTrue(bitmap.ColorsAreEqual(diff.image[1][0], (0, 0, 0)))
131 self.assertTrue(bitmap.ColorsAreEqual(diff.image[0][1], (0, 0, 0)))
123 132
124 diff_bmp.GetPixelColor(0, 0).AssertIsRGB(0, 0, 0) 133 diff = file_bmp.Diff(file_bmp_2)
125 diff_bmp.GetPixelColor(1, 1).AssertIsRGB(0, 0, 0)
126 diff_bmp.GetPixelColor(0, 1).AssertIsRGB(0, 0, 0)
127 diff_bmp.GetPixelColor(1, 0).AssertIsRGB(0, 0, 0)
128 134
129 diff_bmp = file_bmp.Diff(file_bmp_2) 135 self.assertEquals(3, diff.width)
136 self.assertEquals(3, diff.height)
130 137
131 self.assertEquals(3, diff_bmp.width) 138 self.assertTrue(bitmap.ColorsAreEqual(diff.image[0][0], (255, 255, 0)))
132 self.assertEquals(3, diff_bmp.height) 139 self.assertTrue(bitmap.ColorsAreEqual(diff.image[1][1], (255, 0, 255)))
140 self.assertTrue(bitmap.ColorsAreEqual(diff.image[1][0], (0, 255, 255)))
141 self.assertTrue(bitmap.ColorsAreEqual(diff.image[0][1], (255, 0, 0)))
133 142
134 diff_bmp.GetPixelColor(0, 0).AssertIsRGB(0, 255, 255) 143 self.assertTrue(bitmap.ColorsAreEqual(diff.image[2][0], (255, 255, 255)))
135 diff_bmp.GetPixelColor(1, 1).AssertIsRGB(255, 0, 255) 144 self.assertTrue(bitmap.ColorsAreEqual(diff.image[2][1], (255, 255, 255)))
136 diff_bmp.GetPixelColor(0, 1).AssertIsRGB(255, 255, 0) 145 self.assertTrue(bitmap.ColorsAreEqual(diff.image[0][2], (255, 255, 255)))
137 diff_bmp.GetPixelColor(1, 0).AssertIsRGB(0, 0, 255) 146 self.assertTrue(bitmap.ColorsAreEqual(diff.image[1][2], (255, 255, 255)))
147 self.assertTrue(bitmap.ColorsAreEqual(diff.image[2][2], (255, 255, 255)))
138 148
139 diff_bmp.GetPixelColor(0, 2).AssertIsRGB(255, 255, 255)
140 diff_bmp.GetPixelColor(1, 2).AssertIsRGB(255, 255, 255)
141 diff_bmp.GetPixelColor(2, 0).AssertIsRGB(255, 255, 255)
142 diff_bmp.GetPixelColor(2, 1).AssertIsRGB(255, 255, 255)
143 diff_bmp.GetPixelColor(2, 2).AssertIsRGB(255, 255, 255)
144
145 @benchmark.Disabled
146 def testGetBoundingBox(self): 149 def testGetBoundingBox(self):
147 pixels = [0,0,0, 0,0,0, 0,0,0, 0,0,0, 150 pixels = [0,0,0, 0,0,0, 0,0,0, 0,0,0,
148 0,0,0, 1,0,0, 1,0,0, 0,0,0, 151 0,0,0, 1,0,0, 1,0,0, 0,0,0,
149 0,0,0, 0,0,0, 0,0,0, 0,0,0] 152 0,0,0, 0,0,0, 0,0,0, 0,0,0]
150 bmp = bitmap.Bitmap(3, 4, 3, pixels) 153 bmp = bitmap.Bitmap.FromRGBPixels(4, 3, pixels)
151 box, count = bmp.GetBoundingBox(bitmap.RgbaColor(1, 0, 0)) 154 box, count = bmp.GetBoundingBox((0, 0, 1))
152 self.assertEquals(box, (1, 1, 2, 1)) 155 self.assertEquals(box, (1, 1, 2, 1))
153 self.assertEquals(count, 2) 156 self.assertEquals(count, 2)
154 157
155 box, count = bmp.GetBoundingBox(bitmap.RgbaColor(0, 1, 0)) 158 box, count = bmp.GetBoundingBox((0, 1, 0))
156 self.assertEquals(box, None) 159 self.assertEquals(box, None)
157 self.assertEquals(count, 0) 160 self.assertEquals(count, 0)
158 161
159 @benchmark.Disabled
160 def testCrop(self): 162 def testCrop(self):
161 pixels = [0,0,0, 1,0,0, 2,0,0, 3,0,0, 163 pixels = [0,0,0, 1,0,0, 2,0,0, 3,0,0,
162 0,1,0, 1,1,0, 2,1,0, 3,1,0, 164 0,1,0, 1,1,0, 2,1,0, 3,1,0,
163 0,2,0, 1,2,0, 2,2,0, 3,2,0] 165 0,2,0, 1,2,0, 2,2,0, 3,2,0]
164 bmp = bitmap.Bitmap(3, 4, 3, pixels) 166 bmp = bitmap.Bitmap.FromRGBPixels(4, 3, pixels)
165 bmp.Crop(1, 2, 2, 1) 167 bmp.Crop(1, 2, 2, 1)
166 168
167 self.assertEquals(bmp.width, 2) 169 self.assertEquals(bmp.width, 2)
168 self.assertEquals(bmp.height, 1) 170 self.assertEquals(bmp.height, 1)
169 bmp.GetPixelColor(0, 0).AssertIsRGB(1, 2, 0)
170 bmp.GetPixelColor(1, 0).AssertIsRGB(2, 2, 0)
171 self.assertEquals(bmp.pixels, bytearray([1,2,0, 2,2,0]))
172 171
173 @benchmark.Disabled 172 self.assertTrue(bitmap.ColorsAreEqual(bmp.image[0][0], (0, 2, 1)))
173 self.assertTrue(bitmap.ColorsAreEqual(bmp.image[0][1], (0, 2, 2)))
174
174 def testHistogram(self): 175 def testHistogram(self):
175 pixels = [1,2,3, 1,2,3, 1,2,3, 1,2,3, 176 pixels = [1,2,3, 1,2,3, 1,2,3, 1,2,3,
176 1,2,3, 8,7,6, 5,4,6, 1,2,3, 177 1,2,3, 8,7,6, 5,4,6, 1,2,3,
177 1,2,3, 8,7,6, 5,4,6, 1,2,3] 178 1,2,3, 8,7,6, 5,4,6, 1,2,3]
178 bmp = bitmap.Bitmap(3, 4, 3, pixels) 179 bmp = bitmap.Bitmap.FromRGBPixels(4, 3, pixels)
179 bmp.Crop(1, 1, 2, 2) 180 bmp.Crop(1, 1, 2, 2)
180 181
181 histogram = bmp.ColorHistogram() 182 histogram = bmp.ColorHistogram()
182 for i in xrange(3): 183 for i in xrange(3):
183 self.assertEquals(sum(histogram[i]), bmp.width * bmp.height) 184 self.assertEquals(sum(histogram[i]), bmp.width * bmp.height)
184 self.assertEquals(histogram.r[1], 0) 185 self.assertEquals(histogram.r[1], 0)
185 self.assertEquals(histogram.r[5], 2) 186 self.assertEquals(histogram.r[5], 2)
186 self.assertEquals(histogram.r[8], 2) 187 self.assertEquals(histogram.r[8], 2)
187 self.assertEquals(histogram.g[2], 0) 188 self.assertEquals(histogram.g[2], 0)
188 self.assertEquals(histogram.g[4], 2) 189 self.assertEquals(histogram.g[4], 2)
189 self.assertEquals(histogram.g[7], 2) 190 self.assertEquals(histogram.g[7], 2)
190 self.assertEquals(histogram.b[3], 0) 191 self.assertEquals(histogram.b[3], 0)
191 self.assertEquals(histogram.b[6], 4) 192 self.assertEquals(histogram.b[6], 4)
192 193
193 @benchmark.Disabled
194 def testHistogramIgnoreColor(self): 194 def testHistogramIgnoreColor(self):
195 pixels = [1,2,3, 1,2,3, 1,2,3, 1,2,3, 195 pixels = [1,2,3, 1,2,3, 1,2,3, 1,2,3,
196 1,2,3, 8,7,6, 5,4,6, 1,2,3, 196 1,2,3, 8,7,6, 5,4,6, 1,2,3,
197 1,2,3, 8,7,6, 5,4,6, 1,2,3] 197 1,2,3, 8,7,6, 5,4,6, 1,2,3,
198 bmp = bitmap.Bitmap(3, 4, 3, pixels) 198 1,2,3, 1,2,2, 2,2,3, 1,2,3]
199 bmp = bitmap.Bitmap.FromRGBPixels(4, 4, pixels)
199 200
200 histogram = bmp.ColorHistogram(ignore_color=bitmap.RgbaColor(1, 2, 3)) 201 histogram = bmp.ColorHistogram(ignore_color=(3, 2, 1))
201 self.assertEquals(histogram.r[1], 0) 202 self.assertEquals(histogram.r[1], 1)
203 self.assertEquals(histogram.r[2], 1)
202 self.assertEquals(histogram.r[5], 2) 204 self.assertEquals(histogram.r[5], 2)
203 self.assertEquals(histogram.r[8], 2) 205 self.assertEquals(histogram.r[8], 2)
204 self.assertEquals(histogram.g[2], 0) 206 self.assertEquals(histogram.g[2], 2)
205 self.assertEquals(histogram.g[4], 2) 207 self.assertEquals(histogram.g[4], 2)
206 self.assertEquals(histogram.g[7], 2) 208 self.assertEquals(histogram.g[7], 2)
207 self.assertEquals(histogram.b[3], 0) 209 self.assertEquals(histogram.b[2], 1)
210 self.assertEquals(histogram.b[3], 1)
208 self.assertEquals(histogram.b[6], 4) 211 self.assertEquals(histogram.b[6], 4)
209 212
210 @benchmark.Disabled
211 def testHistogramIgnoreColorTolerance(self): 213 def testHistogramIgnoreColorTolerance(self):
212 pixels = [1,2,3, 4,5,6, 214 pixels = [1,2,3, 4,5,6,
213 7,8,9, 8,7,6] 215 7,8,9, 8,7,6]
214 bmp = bitmap.Bitmap(3, 2, 2, pixels) 216 bmp = bitmap.Bitmap.FromRGBPixels(2, 2, pixels)
215 217
216 histogram = bmp.ColorHistogram(ignore_color=bitmap.RgbaColor(0, 1, 2), 218 histogram = bmp.ColorHistogram(ignore_color=(2, 1, 0), tolerance=1)
217 tolerance=1)
218 self.assertEquals(histogram.r[1], 0) 219 self.assertEquals(histogram.r[1], 0)
219 self.assertEquals(histogram.r[4], 1) 220 self.assertEquals(histogram.r[4], 1)
220 self.assertEquals(histogram.r[7], 1) 221 self.assertEquals(histogram.r[7], 1)
221 self.assertEquals(histogram.r[8], 1) 222 self.assertEquals(histogram.r[8], 1)
222 self.assertEquals(histogram.g[2], 0) 223 self.assertEquals(histogram.g[2], 0)
223 self.assertEquals(histogram.g[5], 1) 224 self.assertEquals(histogram.g[5], 1)
224 self.assertEquals(histogram.g[7], 1) 225 self.assertEquals(histogram.g[7], 1)
225 self.assertEquals(histogram.g[8], 1) 226 self.assertEquals(histogram.g[8], 1)
226 self.assertEquals(histogram.b[3], 0) 227 self.assertEquals(histogram.b[3], 0)
227 self.assertEquals(histogram.b[6], 2) 228 self.assertEquals(histogram.b[6], 2)
228 self.assertEquals(histogram.b[9], 1) 229 self.assertEquals(histogram.b[9], 1)
229 230
230 @benchmark.Disabled
231 def testHistogramDistanceIgnoreColor(self): 231 def testHistogramDistanceIgnoreColor(self):
232 pixels = [1,2,3, 1,2,3, 232 pixels = [1,2,3, 1,2,3,
233 1,2,3, 1,2,3] 233 1,2,3, 1,2,3]
234 bmp = bitmap.Bitmap(3, 2, 2, pixels) 234 bmp = bitmap.Bitmap.FromRGBPixels(2, 2, pixels)
235 235
236 hist1 = bmp.ColorHistogram(ignore_color=bitmap.RgbaColor(1, 2, 3)) 236 hist1 = bmp.ColorHistogram(ignore_color=(1, 2, 3))
237 hist2 = bmp.ColorHistogram() 237 hist2 = bmp.ColorHistogram()
238 238
239 self.assertEquals(hist1.Distance(hist2), 0) 239 self.assertEquals(hist1.Distance(hist2), 0)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698