I would like to generate a skeleton out of an image. The resulting output of the skeleton image has disconnected edges.
import skimage from skimage import data,io,filters import numpy as np import cv2 import matplotlib.pyplot as plt from skimage.filters import threshold_adaptive,threshold_mean from skimage.morphology import binary_dilation from skimage import feature from skimage.morphology import skeletonize_3d
imgfile = "Bagah.jpeg" im = cv2.imread(imgfile) image = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY) thresh = threshold_mean(image) thresh = threshold_mean(thresh)
binary = image > thresh #dilate = skimage.morphology.binary_dilation(binary) gaussian = skimage.filters.gaussian(binary) edges = filters.sobel(gaussian) #dilate = feature.canny(edges)#binary,sigma=0) skeleton = skeletonize_3d(gaussian)#binary) fig, axes = plt.subplots(nrows=2,ncols=2, figsize=(8, 2)) ax = axes.ravel() ax[0].imshow(gaussian, cmap=plt.cm.gray) ax[0].set_title('gaussian')
ax[1].imshow(skeleton, cmap=plt.cm.gray) ax[1].set_title('skeleton') for a in ax: a.axis('off')
plt.show()
Please find the attachments of my input and output files. I would like to translate this skeleton into a graph with nodes and edges. Could someone suggest how to obtain a skeleton with connected edges?
https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=4a1c8db3-b2fd-4efa-85ef-887e08f50a6b I’m protected online with Avast Free Antivirus. Get it here — it’s free forever. https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=4a1c8db3-b2fd-4efa-85ef-887e08f50a6b <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
I need solution for same. Pls share.
On Thu, 29 Nov 2018, 16:37 Deepa, deepamahm.iisc@gmail.com wrote:
I would like to generate a skeleton out of an image. The resulting output of the skeleton image has disconnected edges.
import skimage from skimage import data,io,filters import numpy as np import cv2 import matplotlib.pyplot as plt from skimage.filters import threshold_adaptive,threshold_mean from skimage.morphology import binary_dilation from skimage import feature from skimage.morphology import skeletonize_3d
imgfile = "Bagah.jpeg" im = cv2.imread(imgfile) image = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY) thresh = threshold_mean(image) thresh = threshold_mean(thresh)
binary = image > thresh #dilate = skimage.morphology.binary_dilation(binary) gaussian = skimage.filters.gaussian(binary) edges = filters.sobel(gaussian) #dilate = feature.canny(edges)#binary,sigma=0) skeleton = skeletonize_3d(gaussian)#binary) fig, axes = plt.subplots(nrows=2,ncols=2, figsize=(8, 2)) ax = axes.ravel() ax[0].imshow(gaussian, cmap=plt.cm.gray) ax[0].set_title('gaussian')
ax[1].imshow(skeleton, cmap=plt.cm.gray) ax[1].set_title('skeleton') for a in ax: a.axis('off')
plt.show()
Please find the attachments of my input and output files. I would like to translate this skeleton into a graph with nodes and edges. Could someone suggest how to obtain a skeleton with connected edges?
https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=4a1c8db3-b2fd-4efa-85ef-887e08f50a6b I’m protected online with Avast Free Antivirus. Get it here — it’s free forever. https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=4a1c8db3-b2fd-4efa-85ef-887e08f50a6b <#m_2144666875335693240_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> _______________________________________________ scikit-image mailing list -- scikit-image@python.org To unsubscribe send an email to scikit-image-leave@python.org
I have successfully extracted nodes(nodes), edges(lines), arrows from image. Facing difficulty in finding Relations and indegree & outdegree of node. sample input and output image is attached.
On Thu, Nov 29, 2018 at 5:08 PM Leena Chourey leenagour@gmail.com wrote:
I need solution for same. Pls share.
On Thu, 29 Nov 2018, 16:37 Deepa, deepamahm.iisc@gmail.com wrote:
I would like to generate a skeleton out of an image. The resulting output of the skeleton image has disconnected edges.
import skimage from skimage import data,io,filters import numpy as np import cv2 import matplotlib.pyplot as plt from skimage.filters import threshold_adaptive,threshold_mean from skimage.morphology import binary_dilation from skimage import feature from skimage.morphology import skeletonize_3d
imgfile = "Bagah.jpeg" im = cv2.imread(imgfile) image = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY) thresh = threshold_mean(image) thresh = threshold_mean(thresh)
binary = image > thresh #dilate = skimage.morphology.binary_dilation(binary) gaussian = skimage.filters.gaussian(binary) edges = filters.sobel(gaussian) #dilate = feature.canny(edges)#binary,sigma=0) skeleton = skeletonize_3d(gaussian)#binary) fig, axes = plt.subplots(nrows=2,ncols=2, figsize=(8, 2)) ax = axes.ravel() ax[0].imshow(gaussian, cmap=plt.cm.gray) ax[0].set_title('gaussian')
ax[1].imshow(skeleton, cmap=plt.cm.gray) ax[1].set_title('skeleton') for a in ax: a.axis('off')
plt.show()
Please find the attachments of my input and output files. I would like to translate this skeleton into a graph with nodes and edges. Could someone suggest how to obtain a skeleton with connected edges?
https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=4a1c8db3-b2fd-4efa-85ef-887e08f50a6b I’m protected online with Avast Free Antivirus. Get it here — it’s free forever. https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=4a1c8db3-b2fd-4efa-85ef-887e08f50a6b <#m_-605135910361920581_m_7430415789251021552_m_2144666875335693240_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> _______________________________________________ scikit-image mailing list -- scikit-image@python.org To unsubscribe send an email to scikit-image-leave@python.org
You might need an algorithm to determine the branch point ("nodes"). I think there were some research papers dealing with this problem.
Looks to me that the original picture would be better for finding the "nodes." One algorithm could be the following:
Step 1: Use a circle with a variable radius to cut the image. (if you do not want to use the circle, you can use a rectangle.) Step 2: Find the connected components inside of the circle (that is the boundary of a disk). If there are more than two components, you need to reduce the size of the circle. If there is no component, you need to enlarge the size of the circle. Repeat Step 2. Step 3: (Now we only have one component inside of the circle) Find if there are three or more disconnected intersections on the circle (not the disk, just the boundary---the circle). If it is true, you find the "node." (To determine where is the node, you might need to reduce the size of the circle again. ) If there only one or two disconnected intersections, the region inside of the circle does not have a "node." (Step 4: Scan through all points in the image. You may find some nodes that are closely connected, in this case, you need to find the best one.)
This algorithm is just based on the mathematical definition of the branch point. There might be a better algorithm than the above one. Hope it helps.
I will share this question with my students. If they can code this one, we will email you the solution.
Lee Chen lchenudc@gmail.com
On Thu, Nov 29, 2018 at 6:08 AM Deepa deepamahm.iisc@gmail.com wrote:
I would like to generate a skeleton out of an image. The resulting output of the skeleton image has disconnected edges.
import skimage from skimage import data,io,filters import numpy as np import cv2 import matplotlib.pyplot as plt from skimage.filters import threshold_adaptive,threshold_mean from skimage.morphology import binary_dilation from skimage import feature from skimage.morphology import skeletonize_3d
imgfile = "Bagah.jpeg" im = cv2.imread(imgfile) image = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY) thresh = threshold_mean(image) thresh = threshold_mean(thresh)
binary = image > thresh #dilate = skimage.morphology.binary_dilation(binary) gaussian = skimage.filters.gaussian(binary) edges = filters.sobel(gaussian) #dilate = feature.canny(edges)#binary,sigma=0) skeleton = skeletonize_3d(gaussian)#binary) fig, axes = plt.subplots(nrows=2,ncols=2, figsize=(8, 2)) ax = axes.ravel() ax[0].imshow(gaussian, cmap=plt.cm.gray) ax[0].set_title('gaussian')
ax[1].imshow(skeleton, cmap=plt.cm.gray) ax[1].set_title('skeleton') for a in ax: a.axis('off')
plt.show()
Please find the attachments of my input and output files. I would like to translate this skeleton into a graph with nodes and edges. Could someone suggest how to obtain a skeleton with connected edges?
https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=4a1c8db3-b2fd-4efa-85ef-887e08f50a6b I’m protected online with Avast Free Antivirus. Get it here — it’s free forever. https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=4a1c8db3-b2fd-4efa-85ef-887e08f50a6b <#m_7957197479038910600_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> _______________________________________________ scikit-image mailing list -- scikit-image@python.org To unsubscribe send an email to scikit-image-leave@python.org