fit rectangles into a 2D shape within an image using either Matlab or Python

Job ID: 35909977

Budget: $10 – $30 USD

The task at hand requires some programming skills and a basic understanding of math. There are some images, each depicting a shape such as a handwritten digit, alphabet, etc. The physical dimensions of the shape are approximately 3 by 3 micrometers. The goal is to fit smaller rectangles (with side lengths between 20 nm and 500 nm) into the object shape (general 2D shapes) in an optimized manner. The rectangles should be either vertical or horizontal and their arrangement, size, and number should be optimized so that the sum of the rectangles closely resembles the original image.

The shape of the objective is general, it could be images of digits, alphabets or simple objects like the attached images.

The script should be able to read an image and return the optimized length (a) and width (b) of the rectangles, their central position, and an indicator of how well the shape is approximated by the rectangles. Gaussian process regression (Bayesian optimization) is a suitable method to solve this problem. The code should be well-commented for easy understanding.