Skip to main content

CV Slicer

Project description

CV Slicer - Python3 Package

Handling the slicing of enormously large image without compromising quality or information. Specially made for computer vision object detection.

Usage

To install this package:

pip install cvslicer

To import:

import cvslicer

To use:

  • We need to have 2 parameters ( in pixels ),
  1. The maximum size of image after sliced.
  2. The maximum size of object for detection.
# 100, 100: Image CutOff Height and Width
# 40, 40: Object Maximum Height and Width
img_slicer = cvslicer.CVSlicer(img_path, 100, 100, 40, 40)  

# Below function gives you a 2D array with the below elements 
# [ image file path, [x-coordinate to shift, y-coordinate to shift]  ]
print(img_slicer.slice_img())  

You may refer here for sample usage.

Overview



Say, you have extremely large dimension images like floor plans, maps, building layout, etc. You want to use them with your object detection model. Sometimes, it might have some compatibility issues with some models or some programs might not be taking images in such an enormous dimension.

There are some workarounds, ie.
(1) Downsize the image dimension by losing quality.
(2) Crop/Slice the image into smaller pieces.

Both the above methods will cause you to lose information. Particularly for (2), if your object gets sliced in half within the borders of cropped image, it will not be detected.

Thus, here comes the purpose of CV Slicer. It is a Python-3 package which is made to handle the issues mentioned in (1) and (2) above. It is made to be compatible with OpenCV.

On the other hand, CV Slicer may also help those who wish to load large image in OpenCV. OpenCV limits the size of image up to a certain constant ( you may refer here: https://github.com/opencv/opencv/blob/8eba3c1e7e8975ff1d263a41a5753efaa51d54fc/modules/imgcodecs/src/loadsave.cpp#L61).

To bypass that limit, you have to apply some hacks by changing the environment variable (for newer version only) or by redefining the constants and recompile the whole OpenCV package again. But if you wish to avoid or are unable to do that, you may use CV Slicer too.

Concepts & Documentations

In brief, if we are to sliced the image below into smaller pieces, we are going to slice it into 9 smaller pieces. The 4 pieces are the main pieces. While for the 5th - 9th pieces, they are strips above the borders, their width and height are determined by the size of the object that you are detecting. Those strips are to prevent the case where your object gets sliced in half within the borders of the first 4 pieces that we sliced.

For more details please refer here






License

MIT License

Author

Quek JY

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cvslicer-1.0.1.tar.gz (10.7 kB view hashes)

Uploaded Source

Built Distribution

cvslicer-1.0.1-py3-none-any.whl (9.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page