Contours ढूँढना

Python में इमेज प्रोसेसिंग

Rebeca Gonzalez

Data Engineer

Contours ढूँढना

  • आकार मापें
  • आकृतियाँ वर्गीकृत करें
  • ऑब्जेक्ट्स की संख्या तय करें

डोमिनो टोकन्स में कुल पॉइंट्स: 29.

Python में इमेज प्रोसेसिंग

बाइनरी इमेजेज

हम thresholding या edge detection लगाकर बाइनरी इमेज पा सकते हैं

Python में इमेज प्रोसेसिंग

scikit-image से contours ढूँढें

इमेज तैयार करना

इमेज को 2D ग्रेस्केल में बदलें।

# Make the image grayscale
image = color.rgb2gray(image)

Python में इमेज प्रोसेसिंग

scikit-image से contours ढूँढें

इमेज तैयार करना

इमेज को बाइनराइज़ करें

# Obtain the thresh value
thresh = threshold_otsu(image)

# Apply thresholding
thresholded_image = image > thresh

Python में इमेज प्रोसेसिंग

scikit-image से contours ढूँढें

फिर find_contours() प्रयोग करें।

# Import the measure module
from skimage import measure

# Find contours at a constant value of 0.8
contours = measure.find_contours(thresholded_image, 0.8)

Python में इमेज प्रोसेसिंग

स्थिर लेवल वैल्यू

Python में इमेज प्रोसेसिंग

Contours पहचानने के स्टेप्स

from skimage import measure
from skimage.filters import threshold_otsu

# Make the image grayscale
image = color.rgb2gray(image)

# Obtain the optimal thresh value of the image thresh = threshold_otsu(image) # Apply thresholding and obtain binary image thresholded_image = image > thresh
# Find contours at a constant value of 0.8 contours = measure.find_contours(thresholded_image, 0.8)
Python में इमेज प्रोसेसिंग

Contours पहचानने के स्टेप्स

नतीजा

Python में इमेज प्रोसेसिंग

किसी contour का shape

Contours: (n,2) की लिस्ट - ndarrays.

for contour in contours:
    print(contour.shape)
(433, 2)
(433, 2)
(401, 2)
(401, 2) 
(123, 2)
(123, 2) 
(59, 2)
(59, 2)
(59, 2)
(57, 2)
(57, 2)
(59, 2)
(59, 2)

Python में इमेज प्रोसेसिंग

किसी contour का shape

for contour in contours:
    print(contour.shape)
(433, 2)
(433, 2) --> Outer border
(401, 2)
(401, 2)
(123, 2)
(123, 2)
(59, 2)
(59, 2)
(59, 2)
(57, 2)
(57, 2)
(59, 2)
(59, 2) 

Python में इमेज प्रोसेसिंग

किसी contour का shape

for contour in contours:
    print(contour.shape)
(433, 2)
(433, 2) --> Outer border
(401, 2)
(401, 2) --> Inner border
(123, 2)
(123, 2) 
(59, 2)
(59, 2)
(59, 2)
(57, 2)
(57, 2)
(59, 2)
(59, 2) 

Python में इमेज प्रोसेसिंग

किसी contour का shape

for contour in contours:
    print(contour.shape)
(433, 2)
(433, 2) --> Outer border
(401, 2)
(401, 2) --> Inner border
(123, 2)
(123, 2) --> Divisory line of tokens
(59, 2)
(59, 2)
(59, 2)
(57, 2)
(57, 2)
(59, 2)
(59, 2) 

Python में इमेज प्रोसेसिंग

किसी contour का shape

for contour in contours:
    print(contour.shape)
(433, 2)
(433, 2) --> Outer border
(401, 2)
(401, 2) --> Inner border
(123, 2)
(123, 2) --> Divisory line of tokens
(59, 2)
(59, 2)
(59, 2)
(57, 2)
(57, 2)
(59, 2)
(59, 2) --> Dots 

डॉट्स की संख्या: 7.

Python में इमेज प्रोसेसिंग

अभ्यास करते हैं!

Python में इमेज प्रोसेसिंग

Preparing Video For Download...