Skip to main content

Extract and Merge image patches for easy, fast and self-contained digital image processing and deep learning model training.

Project description

License: MIT Generic badge Downloads

Extract and Merge Image Patches (EMPatches)

Extract and Merge image patches for easy, fast and self-contained digital image processing and deep learning model training.

  • Extract patches
  • Merge the extracted patches to obtain the original image back.

Dependencies

python >= 3.6
numpy 
math

Usage

Extracting Patches

from empatches import EMPatches

# get image either RGB or Grayscale
img = cv2.imread('../penguin.jpg')
# load module
emp = EMPatches()
img_patches, indices = emp.extract_patches(img, patchsize=32, overlap=0.2)

# displaying an image patch
plt.figure()
plt.imshow(img_patches[0])

Image Processing

Now we can perform our operation on each patch independently and after we are done we can merge them back together.

'''
pseudo code
'''
# do some processing, just store the patches in the list in same order
img_patches_processed = some_processing_func(img_patches)
# or run your deep learning model on patches independently and then merge the predictions
img_patches_processed = model.predict(img_patches)

Merging Patches

After processing the patches if you can merge all of them back in original form as follows,

merged_img = emp.merge_patches(img_patches_processed, indices)
# display
plt.figure()
plt.imshow(merged_img)

More Examples

For further details and more examples visit my github

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

empatches-0.1.1.tar.gz (3.5 kB view hashes)

Uploaded Source

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