in groups/arm/ggd/image_processor.py [0:0]
def identify_pixel_objects(self, bw_rows):
# make PixelObjects when pixels are direct 8-neighbours of each other
for j in range(96):
for i in range(96):
if bw_rows[j][i] == 255: # if the pixel is white
tmp_list = []
for ent in self.neighbors((i, j), 96, 96):
tmp_x, tmp_y = ent
if bw_rows[tmp_y][tmp_x] == 255: # if pixel is white
tmp_list.append(ent)
# print tmp_list
flag = False
for obj in self.pixelObjList:
# make a new PixelObj whenever a Pixel isn't connected
# to an object
if obj.check_xy_set(tmp_list) is True:
flag = True
if flag is False:
self.pixelObjList.append(
PixelObject(self.next_obj_id()))
for obj in self.pixelObjList:
obj.check_xy_set(tmp_list)
for obj in self.pixelObjList:
rows = []
for _ in range(96):
rows.append(range(96))
for j in range(96):
for i in range(96):
if (i, j) in obj.XYset:
rows[j][i] = 255
else:
rows[j][i] = 0
# self.save_PNG(string.join([str(obj.id_), 'processed_5.png'], ''), rows)
self.merge_overlapping_pixel_objects()