Coder Social home page Coder Social logo

Comments (2)

JUGGHM avatar JUGGHM commented on June 7, 2024

Thanks for your interest! The input data is down-sampled 5 times so both the height and width must be integer multiple of 2^5=32. So you could crop the width to 352 pixels or pad it to 384 pixels.

from penet_icra2021.

gilotch avatar gilotch commented on June 7, 2024

Thank you for your answer!
I did follow your advice and center crop height down to 352 pixels for both inputs (rgb and depth). As there was still some remaining issues with an error mentioning 'channels', I checked the mode of my color image input and I was indeed in "RGBA". After converting the color image from "RGBA" to "RGB", the code finally worked normally.

from PIL import Image

def crop_center(pil_img, crop_width, crop_height):
    img_width, img_height = pil_img.size
    return pil_img.crop(((img_width - crop_width) // 2,
                         (img_height - crop_height) // 2,
                         (img_width + crop_width) // 2,
                         (img_height + crop_height) // 2))

def resize_image(image_path):
    im = Image.open(image_path)
    im_new = crop_center(im, 32*int(im.size[0]/32), 32*int(im.size[1]/32))
    if (im_new.mode == 'RGBA'):
        im_new = im_new.convert('RGB')
    im_new.save(image_path, quality=95)

from penet_icra2021.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.