Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
wurenkai authored Dec 1, 2023
1 parent 9a1204b commit 318fe0b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
45 changes: 45 additions & 0 deletions Prepare_Neg_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
import h5py
import numpy as np
import scipy.io as sio
import scipy.misc as sc
import glob

# Parameters
height = 256
width = 256
channels = 3

############################################################# Prepare NormalSkin data set #################################################


Tr_list = glob.glob("Normal(Healthy skin)"+'/*.png')
Data_train_2018 = np.zeros([200, height, width, channels])
Label_train_2018 = np.zeros([200, height, width])

print(len(Tr_list))
for idx in range(len(Tr_list)):
print(idx+1)
img = sc.imread(Tr_list[idx])
img = np.double(sc.imresize(img, [height, width, channels], interp='bilinear', mode = 'RGB'))
Data_train_2018[idx, :,:,:] = img

b = Tr_list[idx]
b = b[len(b)-8: len(b)-4]
add = ("masks_black/" + b +'.png')
img2 = sc.imread(add)
img2 = np.double(sc.imresize(img2, [height, width], interp='bilinear'))
Label_train_2018[idx, :,:] = img2

print('finished')

Test_img = Data_train_2018[0:200,:,:,:]

Test_mask = Label_train_2018[0:200,:,:]


np.save('data_test' , Test_img)

np.save('mask_test' , Test_mask)


15 changes: 15 additions & 0 deletions generate_black.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os
from PIL import Image
import numpy as np

folder = 'masks_black'
if not os.path.exists(folder):
os.makedirs(folder)

for i in range(200):
image = np.zeros((256,256), dtype=np.uint8)
img = Image.fromarray(image)
name = os.path.join(folder, f'{i:04}.png')
img.save(name)

print(f'Generated 200 images at {folder}')

0 comments on commit 318fe0b

Please sign in to comment.