mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-14 11:18:06 +08:00
use break instead of exception
This commit is contained in:
committed by
François Boulogne
parent
80e8544067
commit
aea36e89d1
@@ -458,16 +458,14 @@ def threshold_minimum(image, nbins=256, bias='min'):
|
||||
|
||||
max_iter = 10000
|
||||
smooth_hist = np.copy(hist)
|
||||
try:
|
||||
for counter in range(max_iter):
|
||||
smooth_hist = ndif.uniform_filter1d(smooth_hist, 3)
|
||||
maximums = find_local_maxima(smooth_hist)
|
||||
if len(maximums) < 3:
|
||||
raise StopIteration
|
||||
except StopIteration:
|
||||
if len(maximums) != 2:
|
||||
raise RuntimeError('Unable to find two maxima in histogram')
|
||||
else:
|
||||
for counter in range(max_iter):
|
||||
smooth_hist = ndif.uniform_filter1d(smooth_hist, 3)
|
||||
maximums = find_local_maxima(smooth_hist)
|
||||
if len(maximums) < 3:
|
||||
break
|
||||
if len(maximums) != 2:
|
||||
raise RuntimeError('Unable to find two maxima in histogram')
|
||||
elif counter == max_iter - 1:
|
||||
raise RuntimeError('Maximum iteration reached for histogram histogram'
|
||||
'smoothing')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user