Ejemplo n.º 1
0
def test_pixel_at():
    global image
    size = image_size(image)
    # 2. pixel index to row, col
    assert (500, 2) == pixel_at_index(1700, size)
    # 3. row, col to pixel index
    assert 1700 == index_at_pixel(500, 2, size)
    assert 120400 == index_at_pixel(400, 200, size)
Ejemplo n.º 2
0
    def positive(self):
        if hasattr(self, '_positive'):
            return self._positive, self._positive_size

        TT.debug("Collecting positive samples.")
        self._positive = {}
        self._positive_size = 0
        self._positive_expanded = {}
        for data_file, label_file in self.files:
            labels = load_csv(os.path.join(self.root_path, label_file))
            self._positive[data_file] = labels
            self._positive_size += len(labels)
            self._positive_expanded[data_file] = {}
            for col, row, p in labels:
                self._positive_expanded[data_file][index_at_pixel(col=col, row=row, size=self.image_size)] = p
        TT.debug("Found", self._positive_size, "positive samples.")
        return self.positive