def paintNoise(self, ratio): """Returns a canvas filled with random noise using ratio as threshold.""" tmpCanvas = Canvas(self.width, self.height) for b in range(tmpCanvas.getSize()): tmpCanvas._c[b] = False if random.random() > ratio else True return tmpCanvas