Skip to content

Getting fewer images than expected #17

Open
@ghost

Description

Hi,

https://drive.google.com/file/d/14eJIc8H2fa0fu6afUaJ44D1n8YKsoeSI/view?usp=sharing

I am running this code to patchify a large satellite image (above). Per the dimensions of the image (9728x3840 pixels) I am supposed to be getting 570 patches in total, however I end up with less patches (542). Any help as to what I might be missing? Link to image above...

import numpy as np
from matplotlib import pyplot as plt
from patchify import patchify
import tifffile as tiff
import cv2

img = cv2.imread("D:/patchify tests/satellite image/crop_.tif")
patches_img = patchify(img, (256,256,3), step=256)

for i in range(patches_img.shape[0]):
for j in range(patches_img.shape[1]):
single_patch_img = patches_img[i, j, 0, :, :]
if not cv2.imwrite('C:/Users/Downloads/patches/' + 'image_' +
str(i)+str(j)+'.png', single_patch_img):
raise Exception("Could not write the image")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions