Created
May 10, 2019 16:44
-
-
Save muthuspark/25ebe61b11617f86668655326ea3a82d to your computer and use it in GitHub Desktop.
Revisions
-
muthuspark renamed this gist
May 10, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ def run_length_smoothing(X, run_length_width): for index, intensity in enumerate(X): if intensity == 1 and len(block) <= run_length_width: for j in block: X[j] = 1 block = [] -
muthuspark created this gist
May 10, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ X = [0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,1,0,1,1,1,1,0,0,0,1,1,1,0,0,0,0,1] def run_length_smoothing(X, run_length_width): block = [] for index, intensity in enumerate(X): if intensity == 1 and len(block) <= run_length_width: for j in block: X[j] = 1 block = [] elif intensity == 1 and len(block) > run_length_width: block = [] elif intensity == 0: block.append(index) return X print(run_length_smoothing(X,3)) #show image binary_c = np.copy(binary) for ri in range(binary_c.shape[0]): binary_c[ri,:] = run_length_smoothing(binary_c[ri,:], 10) plt.figure(figsize=(20,20)) plt.imshow(binary_c, cmap="gray") plt.show()