def browse_images(caller):
    root.withdraw()
    files_address = askopenfilenames()
    try:
        # change image to binary thens store in array
        raws = [(Image.open(imageAddress)) for imageAddress in files_address]

        # Clipping
        images = []
        for image in raws:
            images.extend(futil.image_clip(image))

        for image in images:
            caller.put_image(image)

    except Exception:
        showerror('Failed', 'One file or more is not an image')
    finally:
        root.deiconify()
Exemple #2
0
            continue

        items.append(os.path.join(subdir, f))

traintype = {}
traincolor = {}
with open('data_type.json') as ft, open('data_color.json') as fc:
    traintype = json.load(ft)
    traincolor = json.load(fc)

for item in items:
    img = Image.open(item)
    img = futil.image_cleanup(img, 20)

    container = {}
    imgs = futil.image_clip(img)
    for obj in imgs:
        shape = fshape.feature_shape_extract(obj)
        color = fcolor.feature_color_extract(obj)
        texture = ftexture.feature_texture_extract(obj)

        # Get Color
        colorval = {}
        colorsum = []
        for key, val in traincolor.iteritems():
            colorval[key] = []
            for feature in val:
                mean = (feature[1][0][0] - color[1][0][0]) ** 2 + (feature[1][0][1] - color[1][0][1]) ** 2 + (feature[1][0][2] - color[1][0][2]) ** 2
                std = (feature[1][1][0] - color[1][1][0]) ** 2 + (feature[1][1][1] - color[1][1][1]) ** 2 + (feature[1][1][2] - color[1][1][2]) ** 2
                skew = (feature[1][2][0] - color[1][2][0]) ** 2 + (feature[1][2][1] - color[1][2][1]) ** 2 + (feature[1][2][2] - color[1][2][2]) ** 2
                colorval[key].append(mean + std + skew)