Open ghost opened 2 years ago
I'm having the same issue. Have you figured out the cause or a solution?
I figured out the issue on my end. Try placing an underscore between the i and j numbers in the filename. Something like this:
# Save patches into new folder
count = 0
for i in range(patches.shape[0]):
for j in range(patches.shape[1]):
count += 1
single_img_patch = patches[i, j, :, :, :]
cv2.imwrite(data_dir + 'patches/' + 'img_' + str(i) + '_' + str(j) + '.png', single_img_patch)
print(count)
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 = patchesimg[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")