INNER CODE UNIT · Python

neighbors

ljvmiranda921/sprites-as-a-service · backend/sprites/sprites.py:140

        neighbors = [(x, y + 1), (x + 1, y), (x, y - 1), (x - 1, y)]
        if orig_val == 0:
            m[idx] = 0  # Set the coordinate in the new matrix as 0
            for n_coord in neighbors:
                try:
                    m[n_coord] = 0.5 if mat[n_coord] == 1 else 0
                except IndexError:
                    pass

    m = np.pad(m, mode="constant", pad_width=1, constant_values=1)

    # I need to switch some values so that I get the colors right.
    # Need to make all 0.5 (outline) as 1, and all 1 (backround)
    # as 0.5
    m[m == 1] = np.inf
    m[m == 0.5] = 1
    m[m == np.inf] = 0.5

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…