Scaling subimage at float coordinates in python

170 Views Asked by At

I would like to know if there is a python library capable of extracting a subimage at supixel precision (float coordinates) and rescaling it to a target size (obviously integer).

Example of what I want to do: Assume we have an image of size 100x100. I want to extract a subimage at coordinates 10.3,10.3 (upper left corner) to 80.6,80.6 (lower right corner). The resulting cut-out has a float size and should be rescaled to 32x32 using bilinear interpolation.

The standard libraries (pil, scipy) offer rescaling functions that work on full images (no subpixel positions), a transformation from int to int coordinates. As described above, I would like to have a transformation from float to int coordinates.

Do I have to implement this myself or would I be reinventing the wheel? So far I haven't seen a standard function that achieves this. I would assume that this is a standard task for image recognition, e.g. when extracting image samples from float detections inside a bigger image.

0

There are 0 best solutions below