Example #1
0
sys.path.append(src_dir)

# for j in  [24]:

j = raw_input("picture number:\n")
width = float(raw_input("width:\n"))
height=float(raw_input("height:\n"))
scale = True
if scale is True:
    directory ='/Users/ruhansa/Desktop/train_buf/train_disc/negative/'+ str(j) + '/'
else:
    directory ='/Users/ruhansa/Desktop/train_buf/train_disc/negative/'+ str(j) + '/'

if not os.path.exists(directory):
    os.makedirs(directory)

fn = xray_dir + '/data/LL/' + str(j) + '.jpg'
arr = filename2arr(fn)

if scale is True:
    from src.utils.util import scale
    ratio_w = 300/ width
    ratio_h = 200/ height
    sw = arr.shape[1] * ratio_w
    sh = arr.shape[0] * ratio_h
    from src.utils.util import scale
    arr = scale(arr, sh, sw)

save_all_sliding_windows(directory, arr, step_size_W=30, step_size_H=30, winW=300, winH=200)
print j
Example #2
0
import os, sys, inspect
from src.utils.io import showimage_pil, filename2arr

tests_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))  # script directory src/
src_dir = os.path.dirname(tests_dir)
xray_dir = os.path.dirname(src_dir)  # xray directory
os.chdir(xray_dir)
sys.path.append(src_dir)

fn = xray_dir + "/data/LL/1.jpg"
arr = filename2arr(fn)

ratio_w = 300 / 450.0
ratio_h = 200 / 376.0
sw = arr.shape[1] * ratio_w
sh = arr.shape[0] * ratio_h
from src.utils.util import scale

arr_new = scale(arr, sh, sw)
showimage_pil(arr)
showimage_pil(arr_new)