rishizek / tensorflow-deeplab-v3

DeepLabv3 built in TensorFlow
MIT License
286 stars 102 forks source link

The mask size differs from the input image size #19

Open Jayanth-L opened 6 years ago

Jayanth-L commented 6 years ago

I understand that there is some resizing due to convolutions, can't i obtain mask with the same size as the input image ?

AlexDenis commented 6 years ago

@Jayanth-L I think so, so I just added white frame removal using ImageChops (piece of code below) and then cv2.resize() to the end of the pipeline:

def trim(im):            
    bg = Image.new(im.mode, im.size, im.getpixel((0,0)))
    diff = ImageChops.difference(im, bg)
    diff = ImageChops.add(diff, diff, 2.0, -100)
    bbox = diff.getbbox()
    if bbox:
        return im.crop(bbox)