I have 357 .bmp images (shape:(357,227,227))
which i read them into numpy array , then I padded them into standard size of
(4608 ,227,227 ). The problem is when I read images from the padded .npy all the
images are showing as black , means all the images are padded with zeros .
I don't know why is padding all the images zeros , I need to keep the images. below is what I tried :
allfiles = os.listdir(pth_upd)
files = []
columns = ['data']
for file in allfiles:
files.append(file) if ('.bmp' in file) else None
samples = np.empty((1,227,227))
for file in files:
img = cv2.imread(os.path.join(pth_upd,file),0)
img = img.reshape(1,227,227)
img=img.astype(np.float32)
samples = np.append(samples, img, axis=0)
if (len(samples)< 4608) :
pad_size=4608-len(samples)
samples = np.pad(samples,(( pad_size,0),(0,0),(0,0)),mode='constant', constant_values=0)
f_name=format(folder)
np.save(f_name, samples)
print('saved')
print(samples.shape)
else:
None