[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
[![Generic badge](https://img.shields.io/badge/Version-0.2.3-<COLOR>.svg)](https://shields.io/) [![Downloads](https://pepy.tech/badge/empatches)](https://pepy.tech/project/empatches) [![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fpypi.org%2Fproject%2Fempatches%2F&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://hits.seeyoufarm.com)
# Extract and Merge Image Patches (EMPatches)
Extract and Merge Batches/Image patches (tf/torch), fast and self-contained digital image processing and deep learning model training.
* **Extract** patches
* **Merge** the extracted patches to obtain the original image back.
### *Upadate 0.2.3 (Bug Fix)*
* While merging tensors.\
thanks [MRLBradley](https://github.com/MRLBradley) for noticing.
### *Upadate 0.2.2 (New Functionalities)*
* Handling 1D spectral and 3D volumetric data structures, thanks to [antonyvam](https://github.com/antonyvam).
* Batch processing support for 1D, 2D, 3D (image/pixel + voxel/volumetric) data added.
* Bug fixes for multi-dimensional image patch merging for `C > 3`.
### *Update 0.2.0*
* Handling of `tensorflow`/`pytorch` **Batched images** of shape `BxCxHxW` -> `pytorch` or `BxHxWxC` -> `tf`. C can be any number not limited to just RGB channels.
* **Modes** added for mergeing patches.
1. `overwrite`: next patch will overwrite the overlapping area of the previous patch.
2. `max` : maximum value of overlapping area at each pixel will be written.
3. `min`: minimum value of overlapping area at each pixel will be written.
4. `avg` : mean/average value of overlapping area at each pixel will be written.
* Patching via providing **Indices**.
* **Strided** patching thanks to [Andreasgejlm](https://github.com/Andreasgejlm)
## Dependencies
```
python >= 3.6
numpy
math
```
# Usage
* [Extracting Patches](#Extracting-Patches)
* [Merging Patches](#Merging-Patches)
* [Voxel/Volumetric Data patching](#Voxel-patching)
* [1D spectral Data patching](#1D-patching)
* [Strided Patching](#Strided-Patching)
* [Batched Patching](#Batched-Patching)
* [Patching via Providing Indices](#Patching-via-Providing-Indices)
## <a name="Extracting-Patches">Extracting Patches</a>
```python
from empatches import EMPatches
import imgviz # just for plotting
# get image either RGB or Grayscale
img = cv2.imread('../digits.jpg')
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
```
![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/digit.jpg)
```python
# load module
emp = EMPatches()
img_patches, indices = emp.extract_patches(img, patchsize=512, overlap=0.2)
# displaying 1st 10 image patches
tiled= imgviz.tile(list(map(np.uint8, img_patches)),border=(255,0,0))
plt.figure()
plt.imshow(tiled)
```
![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/patched.png)
## Image Processing
Now we can perform our operation on each patch independently and after we are done we can merge them back together.
```python
'''
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)
'''For now lets just flip channels'''
img_patches[1] = cv2.cvtColor(img_patches[1], cv2.COLOR_BGR2RGB)
```
![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/patched_process.png)
## <a name="Merging-Patches">Merging-Patches</a>
After processing the patches if you can merge all of them back in original form as follows,
```python
merged_img = emp.merge_patches(img_patches, indices, mode='max') # or
merged_img = emp.merge_patches(img_patches, indices, mode='min') # or
merged_img = emp.merge_patches(img_patches, indices, mode='overwrite') # or
merged_img = emp.merge_patches(img_patches, indices, mode='avg') # or
# display
plt.figure()
plt.imshow(merged_img.astype(np.uint8))
plt.title(Your mode)
```
![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/modesS.png)
## <a name="Strided-Patching">Strided Patching</a>
```python
img_patches, indices = emp.extract_patches(img, patchsize=512, overlap=0.2, stride=128)
tiled= imgviz.tile(list(map(np.uint8, img_patches)),border=(255,0,0))
plt.figure()
plt.imshow(tiled.astype(np.uint8))
plt.title('Strided patching')
```
![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/stride.png)
## <a name="Voxel-patching">Volumetric/Voxel data patching</a>
```python
# first generate a sample data
def midpoints(x):
sl = ()
for i in range(x.ndim):
x = (x[sl + np.index_exp[:-1]] + x[sl + np.index_exp[1:]]) / 2.0
sl += np.index_exp[:]
return x
r, g, b = np.indices((17, 17, 17)) / 16.0
rc = midpoints(r)
gc = midpoints(g)
bc = midpoints(b)
# define a sphere about [0.5, 0.5, 0.5]
sphere = ((rc - 0.5)**2 + (gc - 0.5)**2 + (bc - 0.5)**2 < 0.5**2).astype(int)
ax = plt.figure().add_subplot(projection='3d')
ax.voxels(sphere)
plt.title(f'Voxel 3D data: {sphere.shape} shape')
```
Extract patches from voxel 3D data.
```python
emp = EMPatches()
patches, indices = emp.extract_patches(sphere, patchsize=8, overlap=0.0, stride=None, vox=True)
ax = plt.figure().add_subplot(projection='3d')
ax.voxels(patches[1])
plt.title(f'Patched Voxel 3D data: {patches[0].shape} shape')
for i in range(len(patches)):
print(patches[i].shape)
mp = emp.merge_patches(patches, indices)
```
```
###############___VOXEL DATA___ setting vox to True ########################
## shape indices in xyz dimension
>> (8, 8, 8) (0, 8, 0, 8, 0, 8)
>> (8, 8, 8) (0, 8, 0, 8, 8, 16)
>> (8, 8, 8) (8, 16, 0, 8, 0, 8)
>> (8, 8, 8) (8, 16, 0, 8, 8, 16)
>> (8, 8, 8) (0, 8, 8, 16, 0, 8)
>> (8, 8, 8) (0, 8, 8, 16, 8, 16)
>> (8, 8, 8) (8, 16, 8, 16, 0, 8)
>> (8, 8, 8) (8, 16, 8, 16, 8, 16)
```
![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/v4.png)
### *⚠️NOTE⚠️*
Here the output shape is 8x8x8 i.e. the croping is also done in D/C dimension unlike when we are doing image croping/patching in that case the output would have shape 8x8x3 (RGB) or 8x8 (grayscale), and incides would be like.
```
###############___PIXEL DATA___ -> setting vox to False ########################
## shape indices in xy dimension
>> (8, 8, 16) (0, 8, 0, 8)
>> (8, 8, 16) (8, 16, 0, 8)
>> (8, 8, 16) (0, 8, 8, 16)
>> (8, 8, 16) (8, 16, 8, 16)
```
![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/v3.png)
## <a name="1D-patching">1D spectral Data patching</a>
```python
x1 = np.linspace(0.0, 5.0)
y1 = np.cos(5 * np.pi * x1) * np.exp(-x1)
plt.plot(y1)
plt.title('1D spectra')
emp = EMPatches()
patches, indices = emp.extract_patches(y1, patchsize=8, overlap=0.0, stride=None)
```
![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/1D.png)
```python
ax1 = plt.subplot(1)
plt.plot(patches[0]) # 0th patch
ax2 = plt.subplot(2, sharex=ax1, sharey=ax1)
plt.plot(patches[2]) # 2nd pathc
plt.suptitle('patched 1D spectra')
# merge again
mp = emp.merge_patches(patches, indices)
```
![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/1dp.png)
## <a name="Batched-Patching">Batched Patching</a>
### Things to know.
* batch : Batch of images of shape either BxCxHxW -> pytorch or BxHxWxC -> tf
to extract patches from in list(list1, list2, ...),
where, list1->([H W C], [H W C], ...) and so on.
* patchsize : size of patch to extract from image only square patches can be
extracted for now.
* overlap (Optional): overlap between patched in percentage a float between [0, 1].
* stride (Optional): Step size between patches
* type (Optional): Type of batched images tf or torch type
* batch_patches : a list containing lists of extracted patches of images.
* batch_indices : a list containing lists of indices of patches in order, whihc can be used
at later stage for 'merging_patches'.
* merged_batch : a np array of shape BxCxHxW -> pytorch or BxHxWxC -> tf.
### Extraction
```python
from empatches import BatchPatching
bp = BatchPatching(patchsize=512, overlap=0.2, stride=None, typ='torch')
# extracging
batch_patches, batch_indices = bp.patch_batch(batch) # batch of shape BxCxHxW, C can be any number 3 or greater
plt.imshow(batch_patches[1][2])
plt.title('3rd patch of 2nd image in batch')
```
![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/bp.png)
### Merging
```python
# merging
# output will be of shpae depending on typ variable
# BxCxHxW -> torch or BxHxWxC -> tf
merged_batch = bp.merge_batch(batch_patches, batch_indices, mode='avg')
# accessing the merged images
plt.imshow(merged_batch[1,...].astype(np.uint8))
plt.title('2nd merged image in batch')
```
![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/bm.png)
## <a name="Patching-via-Providing-Indices">Patching via Providing Indices</a>
**NOTE** in this case merging is not supported.
```python
from empatches import patch_via_indices
img = cv2.imread('./digit.jpg')
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
img = cv2.resize(img, (1024, 512))
i = [(0, 512, 0, 256), # 1st patch dims/indices
(0, 256, 310, 922),# 2nd patch dims/indices
(0, 512, 512, 768)]# 3rd patch dims/indices
img_patches = patch_via_indices(img, indices)
# plotting
tiled= imgviz.tile(list(map(np.uint8, img_patches)),border=(255,0,0))
plt.figure()
plt.imshow(tiled.astype(np.uint8))
plt.title('patching via providing indices')
```
![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/p_via_indices.png)
For more infomration visit Homepage.
Raw data
{
"_id": null,
"home_page": "https://github.com/Mr-TalhaIlyas/EMPatches",
"name": "empatches",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "python,extract image patches,merge image patches,patchify,sliding window",
"author": "Talha Ilyas",
"author_email": "mr.talhailyas@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/b7/0a/ca6a71668fdcd4f8908cb76052b56ce09a47eb13ade9f2baf519f1af9bfd/empatches-0.2.3.tar.gz",
"platform": null,
"description": "\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)\r\n [![Generic badge](https://img.shields.io/badge/Version-0.2.3-<COLOR>.svg)](https://shields.io/) [![Downloads](https://pepy.tech/badge/empatches)](https://pepy.tech/project/empatches) [![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fpypi.org%2Fproject%2Fempatches%2F&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://hits.seeyoufarm.com)\r\n\r\n# Extract and Merge Image Patches (EMPatches)\r\n\r\nExtract and Merge Batches/Image patches (tf/torch), fast and self-contained digital image processing and deep learning model training.\r\n\r\n* **Extract** patches\r\n* **Merge** the extracted patches to obtain the original image back.\r\n### *Upadate 0.2.3 (Bug Fix)*\r\n* While merging tensors.\\\r\nthanks [MRLBradley](https://github.com/MRLBradley) for noticing.\r\n\r\n### *Upadate 0.2.2 (New Functionalities)*\r\n\r\n* Handling 1D spectral and 3D volumetric data structures, thanks to [antonyvam](https://github.com/antonyvam).\r\n* Batch processing support for 1D, 2D, 3D (image/pixel + voxel/volumetric) data added.\r\n* Bug fixes for multi-dimensional image patch merging for `C > 3`.\r\n\r\n### *Update 0.2.0*\r\n\r\n* Handling of `tensorflow`/`pytorch` **Batched images** of shape `BxCxHxW` -> `pytorch` or `BxHxWxC` -> `tf`. C can be any number not limited to just RGB channels.\r\n* **Modes** added for mergeing patches.\r\n 1. `overwrite`: next patch will overwrite the overlapping area of the previous patch.\r\n 2. `max` : maximum value of overlapping area at each pixel will be written.\r\n 3. `min`: minimum value of overlapping area at each pixel will be written.\r\n 4. `avg` : mean/average value of overlapping area at each pixel will be written.\r\n* Patching via providing **Indices**.\r\n* **Strided** patching thanks to [Andreasgejlm](https://github.com/Andreasgejlm)\r\n\r\n## Dependencies\r\n\r\n```\r\npython >= 3.6\r\nnumpy \r\nmath\r\n```\r\n\r\n# Usage\r\n* [Extracting Patches](#Extracting-Patches)\r\n* [Merging Patches](#Merging-Patches)\r\n* [Voxel/Volumetric Data patching](#Voxel-patching)\r\n* [1D spectral Data patching](#1D-patching)\r\n* [Strided Patching](#Strided-Patching)\r\n* [Batched Patching](#Batched-Patching)\r\n* [Patching via Providing Indices](#Patching-via-Providing-Indices)\r\n\r\n## <a name=\"Extracting-Patches\">Extracting Patches</a>\r\n```python\r\nfrom empatches import EMPatches\r\nimport imgviz # just for plotting\r\n\r\n# get image either RGB or Grayscale\r\nimg = cv2.imread('../digits.jpg')\r\nimg = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)\r\n```\r\n\r\n![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/digit.jpg)\r\n\r\n```python\r\n# load module\r\nemp = EMPatches()\r\nimg_patches, indices = emp.extract_patches(img, patchsize=512, overlap=0.2)\r\n\r\n# displaying 1st 10 image patches\r\ntiled= imgviz.tile(list(map(np.uint8, img_patches)),border=(255,0,0))\r\nplt.figure()\r\nplt.imshow(tiled)\r\n```\r\n\r\n![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/patched.png)\r\n\r\n## Image Processing\r\nNow we can perform our operation on each patch independently and after we are done we can merge them back together.\r\n\r\n```python\r\n'''\r\npseudo code\r\n'''\r\n# do some processing, just store the patches in the list in same order\r\nimg_patches_processed = some_processing_func(img_patches)\r\n# or run your deep learning model on patches independently and then merge the predictions\r\nimg_patches_processed = model.predict(img_patches)\r\n'''For now lets just flip channels'''\r\nimg_patches[1] = cv2.cvtColor(img_patches[1], cv2.COLOR_BGR2RGB)\r\n```\r\n![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/patched_process.png)\r\n\r\n## <a name=\"Merging-Patches\">Merging-Patches</a>\r\n\r\nAfter processing the patches if you can merge all of them back in original form as follows,\r\n\r\n```python\r\nmerged_img = emp.merge_patches(img_patches, indices, mode='max') # or\r\nmerged_img = emp.merge_patches(img_patches, indices, mode='min') # or\r\nmerged_img = emp.merge_patches(img_patches, indices, mode='overwrite') # or\r\nmerged_img = emp.merge_patches(img_patches, indices, mode='avg') # or\r\n# display\r\nplt.figure()\r\nplt.imshow(merged_img.astype(np.uint8))\r\nplt.title(Your mode)\r\n```\r\n![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/modesS.png)\r\n\r\n## <a name=\"Strided-Patching\">Strided Patching</a>\r\n\r\n```python\r\nimg_patches, indices = emp.extract_patches(img, patchsize=512, overlap=0.2, stride=128)\r\ntiled= imgviz.tile(list(map(np.uint8, img_patches)),border=(255,0,0))\r\nplt.figure()\r\nplt.imshow(tiled.astype(np.uint8))\r\nplt.title('Strided patching')\r\n```\r\n![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/stride.png)\r\n\r\n## <a name=\"Voxel-patching\">Volumetric/Voxel data patching</a>\r\n\r\n```python\r\n# first generate a sample data\r\ndef midpoints(x):\r\n sl = ()\r\n for i in range(x.ndim):\r\n x = (x[sl + np.index_exp[:-1]] + x[sl + np.index_exp[1:]]) / 2.0\r\n sl += np.index_exp[:]\r\n return x\r\nr, g, b = np.indices((17, 17, 17)) / 16.0\r\nrc = midpoints(r)\r\ngc = midpoints(g)\r\nbc = midpoints(b)\r\n# define a sphere about [0.5, 0.5, 0.5]\r\nsphere = ((rc - 0.5)**2 + (gc - 0.5)**2 + (bc - 0.5)**2 < 0.5**2).astype(int)\r\n\r\nax = plt.figure().add_subplot(projection='3d')\r\nax.voxels(sphere)\r\nplt.title(f'Voxel 3D data: {sphere.shape} shape')\r\n```\r\n\r\nExtract patches from voxel 3D data.\r\n\r\n```python\r\nemp = EMPatches()\r\npatches, indices = emp.extract_patches(sphere, patchsize=8, overlap=0.0, stride=None, vox=True)\r\n\r\nax = plt.figure().add_subplot(projection='3d')\r\nax.voxels(patches[1])\r\nplt.title(f'Patched Voxel 3D data: {patches[0].shape} shape')\r\n\r\nfor i in range(len(patches)):\r\n print(patches[i].shape)\r\n\r\nmp = emp.merge_patches(patches, indices)\r\n\r\n```\r\n```\r\n###############___VOXEL DATA___ setting vox to True ########################\r\n## shape indices in xyz dimension\r\n>> (8, 8, 8) (0, 8, 0, 8, 0, 8)\r\n>> (8, 8, 8) (0, 8, 0, 8, 8, 16)\r\n>> (8, 8, 8) (8, 16, 0, 8, 0, 8)\r\n>> (8, 8, 8) (8, 16, 0, 8, 8, 16)\r\n>> (8, 8, 8) (0, 8, 8, 16, 0, 8)\r\n>> (8, 8, 8) (0, 8, 8, 16, 8, 16)\r\n>> (8, 8, 8) (8, 16, 8, 16, 0, 8)\r\n>> (8, 8, 8) (8, 16, 8, 16, 8, 16)\r\n```\r\n![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/v4.png)\r\n\r\n### *\u26a0\ufe0fNOTE\u26a0\ufe0f*\r\nHere the output shape is 8x8x8 i.e. the croping is also done in D/C dimension unlike when we are doing image croping/patching in that case the output would have shape 8x8x3 (RGB) or 8x8 (grayscale), and incides would be like.\r\n\r\n```\r\n###############___PIXEL DATA___ -> setting vox to False ########################\r\n## shape indices in xy dimension\r\n>> (8, 8, 16) (0, 8, 0, 8)\r\n>> (8, 8, 16) (8, 16, 0, 8)\r\n>> (8, 8, 16) (0, 8, 8, 16)\r\n>> (8, 8, 16) (8, 16, 8, 16)\r\n```\r\n![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/v3.png)\r\n\r\n## <a name=\"1D-patching\">1D spectral Data patching</a>\r\n\r\n\r\n```python\r\nx1 = np.linspace(0.0, 5.0)\r\ny1 = np.cos(5 * np.pi * x1) * np.exp(-x1)\r\nplt.plot(y1)\r\nplt.title('1D spectra')\r\n\r\nemp = EMPatches()\r\npatches, indices = emp.extract_patches(y1, patchsize=8, overlap=0.0, stride=None)\r\n```\r\n![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/1D.png)\r\n```python\r\nax1 = plt.subplot(1)\r\nplt.plot(patches[0]) # 0th patch\r\nax2 = plt.subplot(2, sharex=ax1, sharey=ax1)\r\nplt.plot(patches[2]) # 2nd pathc\r\nplt.suptitle('patched 1D spectra')\r\n# merge again\r\nmp = emp.merge_patches(patches, indices)\r\n```\r\n![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/1dp.png)\r\n\r\n## <a name=\"Batched-Patching\">Batched Patching</a>\r\n\r\n### Things to know.\r\n\r\n* batch : Batch of images of shape either BxCxHxW -> pytorch or BxHxWxC -> tf\r\n to extract patches from in list(list1, list2, ...),\r\n where, list1->([H W C], [H W C], ...) and so on.\r\n* patchsize : size of patch to extract from image only square patches can be\r\n extracted for now.\r\n* overlap (Optional): overlap between patched in percentage a float between [0, 1].\r\n* stride (Optional): Step size between patches\r\n* type (Optional): Type of batched images tf or torch type\r\n\r\n* batch_patches : a list containing lists of extracted patches of images.\r\n* batch_indices : a list containing lists of indices of patches in order, whihc can be used \r\n at later stage for 'merging_patches'.\r\n\r\n* merged_batch : a np array of shape BxCxHxW -> pytorch or BxHxWxC -> tf.\r\n\r\n\r\n### Extraction\r\n```python\r\nfrom empatches import BatchPatching\r\n\r\nbp = BatchPatching(patchsize=512, overlap=0.2, stride=None, typ='torch')\r\n# extracging\r\nbatch_patches, batch_indices = bp.patch_batch(batch) # batch of shape BxCxHxW, C can be any number 3 or greater\r\n\r\nplt.imshow(batch_patches[1][2])\r\nplt.title('3rd patch of 2nd image in batch')\r\n```\r\n![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/bp.png)\r\n\r\n### Merging\r\n```python\r\n# merging\r\n# output will be of shpae depending on typ variable\r\n# BxCxHxW -> torch or BxHxWxC -> tf\r\nmerged_batch = bp.merge_batch(batch_patches, batch_indices, mode='avg') \r\n\r\n# accessing the merged images\r\nplt.imshow(merged_batch[1,...].astype(np.uint8))\r\nplt.title('2nd merged image in batch')\r\n```\r\n![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/bm.png)\r\n\r\n## <a name=\"Patching-via-Providing-Indices\">Patching via Providing Indices</a>\r\n\r\n**NOTE** in this case merging is not supported.\r\n\r\n```python\r\nfrom empatches import patch_via_indices\r\n\r\nimg = cv2.imread('./digit.jpg')\r\nimg = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)\r\nimg = cv2.resize(img, (1024, 512))\r\n\r\ni = [(0, 512, 0, 256), # 1st patch dims/indices\r\n (0, 256, 310, 922),# 2nd patch dims/indices\r\n (0, 512, 512, 768)]# 3rd patch dims/indices\r\nimg_patches = patch_via_indices(img, indices)\r\n\r\n# plotting\r\ntiled= imgviz.tile(list(map(np.uint8, img_patches)),border=(255,0,0))\r\nplt.figure()\r\nplt.imshow(tiled.astype(np.uint8))\r\nplt.title('patching via providing indices')\r\n```\r\n\r\n![alt text](https://github.com/Mr-TalhaIlyas/EMPatches/raw/main/screens/p_via_indices.png)\r\n\r\nFor more infomration visit Homepage.\r\n",
"bugtrack_url": null,
"license": "",
"summary": "Extract and Merge Batches/Image patches (tf/torch) for easy, fast and self-contained digital image processing and deep learning model training.",
"version": "0.2.3",
"project_urls": {
"Homepage": "https://github.com/Mr-TalhaIlyas/EMPatches"
},
"split_keywords": [
"python",
"extract image patches",
"merge image patches",
"patchify",
"sliding window"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b70aca6a71668fdcd4f8908cb76052b56ce09a47eb13ade9f2baf519f1af9bfd",
"md5": "24c51432f8ba117177d65fb9317a93e2",
"sha256": "7279224d85225eb9658f8f9c747c7ae1cb807e17814acda24926a394af30ee6e"
},
"downloads": -1,
"filename": "empatches-0.2.3.tar.gz",
"has_sig": false,
"md5_digest": "24c51432f8ba117177d65fb9317a93e2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 11168,
"upload_time": "2023-07-02T00:49:05",
"upload_time_iso_8601": "2023-07-02T00:49:05.107520Z",
"url": "https://files.pythonhosted.org/packages/b7/0a/ca6a71668fdcd4f8908cb76052b56ce09a47eb13ade9f2baf519f1af9bfd/empatches-0.2.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-02 00:49:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Mr-TalhaIlyas",
"github_project": "EMPatches",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "empatches"
}