Skip to content

Commit

Permalink
Cast bools to ints
Browse files Browse the repository at this point in the history
  • Loading branch information
AlainKadar committed Apr 9, 2024
1 parent af79a41 commit d945882
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions StructuralGT/binarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ def binarize_widget(self, Thresh_method, gamma, md_filter, autolvl, g_blur, fg_c

gray_image = cv.imread(self.filename, cv.IMREAD_GRAYSCALE)
Thresh_dict = {'Global':0, 'Adaptive':1, 'OTSU':2}
options_dict = dict(Thresh_method=Thresh_dict[Thresh_method],
options = dict(Thresh_method=Thresh_dict[Thresh_method],
gamma=gamma,
md_filter=md_filter,
g_blur=g_blur,
autolvl=autolvl,
fg_color=fg_color,
laplacian=laplacian,
scharr=scharr,
sobel=sobel,
lowpass=lowpass,
md_filter=int(md_filter),
g_blur=int(g_blur),
autolvl=int(autolvl),
fg_color=int(fg_color),
laplacian=int(laplacian),
scharr=int(scharr),
sobel=int(sobel),
lowpass=int(lowpass),
asize=int(asize)*2+1,
bsize=int(bsize)*2+1,
wsize=int(wsize)*2+1,
Expand All @@ -41,9 +41,9 @@ def binarize_widget(self, Thresh_method, gamma, md_filter, autolvl, g_blur, fg_c
if self.export_dir is None:
self.export_dir = os.path.split(self.filename)[0]
with open(self.export_dir + '/img_options.json', 'w') as fp:
json.dump(options_dict, fp)
json.dump(options, fp)

_, binary_image, _ = process_image.binarize(gray_image, options_dict)
_, binary_image, _ = process_image.binarize(gray_image, options)
plt.imshow(binary_image, cmap='gray')

def __init__(self, filename, export_dir=None):
Expand Down Expand Up @@ -75,8 +75,8 @@ def __init__(self, filename, export_dir=None):
sobel = widgets.Checkbox(description='Sobel', value=0, layout=item_layout)
lowpass = widgets.Checkbox(description='Lowpass', value=0, layout=item_layout)
thr = widgets.FloatSlider(description='Threshold', value=128, min=0, max=256, layout=item_layout)
asize = widgets.FloatSlider(description='Adaptive threshold kernel', value=1, min=1, max=200, layout=item_layout)
bsize = widgets.FloatSlider(description='Blurring kernel size', value=0, min=0, max=10, layout=item_layout)
asize = widgets.FloatSlider(description='Adaptive threshold kernel', value=1, min=1, max=2000, layout=item_layout)
bsize = widgets.FloatSlider(description='Blurring kernel size', value=0, min=0, max=400, layout=item_layout)
wsize = widgets.FloatSlider(description='Window size', value=0, min=0, max=10, layout=item_layout)
export=widgets.Checkbox(description='Export', value=0, layout=item_layout)
w = interactive(self.binarize_widget,
Expand Down

0 comments on commit d945882

Please sign in to comment.