Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save muthuspark/25ebe61b11617f86668655326ea3a82d to your computer and use it in GitHub Desktop.

Select an option

Save muthuspark/25ebe61b11617f86668655326ea3a82d to your computer and use it in GitHub Desktop.

Revisions

  1. muthuspark renamed this gist May 10, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt → gistfile1.py
    Original 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:
    if intensity == 1 and len(block) <= run_length_width:
    for j in block:
    X[j] = 1
    block = []
  2. muthuspark created this gist May 10, 2019.
    28 changes: 28 additions & 0 deletions gistfile1.txt
    Original 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()