Created
August 10, 2021 17:40
-
-
Save dridk/e62e157250bd5419273dfaac9db64be6 to your computer and use it in GitHub Desktop.
image_coord_motif_detection
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 characters
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
from skimage.io import imread | |
from skimage.color import rgb2gray | |
from skimage.filters import threshold_otsu | |
from skimage.measure import label | |
img = imread("A.png") | |
img = rgb2gray(img) | |
thresh = threshold_yen(img) | |
binary = img >= thresh | |
img = label(binary, return_num=False) | |
grp = img.max() | |
plt.imshow(img) | |
for i in range(1, grp+1): | |
points = np.argwhere(img == i) | |
center = points.sum(axis=0) / len(points) | |
plt.plot(center[1], center[0], "ro") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment