예제 #1
0
파일: test_1.py 프로젝트: sssruhan1/xray
b = arr[:, :, 2]
'''

# get morphological image

#from src.morphology import my_erosion
#fn = result_dir + 'erosion'
#eroded = my_erosion(gray, fn, show=False)

#from src.morphology import my_dilation
#fn = result_dir + 'dilation'
#dilated = my_dilation(gray, fn, show=False)

from src.morphology import my_opening
fn = result_dir + 'opening'
opened = my_opening(gray, fn, 50, 1)














예제 #2
0
파일: test_4.py 프로젝트: sssruhan1/xray
height = img.size[1]
arr = np.array(img.getdata(), dtype=np.uint8).reshape(height, width, 3)

# get the gray image
from skimage.color import rgb2gray
gray = rgb2gray(arr)
arr = None
#from src.hist import my_hist
#fn = result_dir + 'gray_hist'
#my_hist(gray, fn)

#from histogram, determine the threshold value min = 0.3, max=0.6 for gray
gray_tmp= np.array(gray)
gray = None
low, high = 0.3, 0.6
idx = low > gray_tmp
gray_tmp[idx] = 0
idx = gray_tmp > high
gray_tmp[idx] = 0
from src.util import saveimage
fn = result_dir + 'thresh_' + str(int(low*10)) + '_' + str(int(high*10))
saveimage(gray_tmp, fn, is_gray=True)

from src.morphology import my_opening
fn = result_dir + 'threshed_opening'
opened = my_opening(gray_tmp, fn, 1, 40)

#diff = gray - opened
#fn = result_dir + 'threshed gray-opening'
#saveimage(diff, fn, is_gray=True)