इस लेख में, हम पायथन 3.x में कनवल्शन के बारे में जानेंगे। या जल्दी। यह लेख तंत्रिका नेटवर्क और फीचर निष्कर्षण के अंतर्गत आते हैं।
पसंदीदा विचार - ज्यूपिटर नोटबुक
आवश्यकताएं - नम्पी स्थापित, Matplotlib स्थापित
इंस्टॉलेशन
>>> pip install numpy >>>pip install matplotlib
कनवल्शन
कनवल्शन एक प्रकार का ऑपरेशन है जिसे छवि पर एक स्लाइडिंग विंडो की तरह कर्नेल / कोऑर्डिनेट कंटेनर नामक एक छोटे कंटेनर को लागू करके उसमें से सुविधाओं को निकालने के लिए किया जा सकता है। कन्वेन्शनल कोऑर्डिनेट कंटेनर में मानों के आधार पर, हम इमेज से विशिष्ट पैटर्न/फीचर्स चुन सकते हैं। यहां, हम उपयुक्त कोऑर्डिनेट कंटेनर्स का उपयोग करके इमेज में हॉरिजॉन्टल और वर्टिकल एंडपॉइंट्स का पता लगाने के बारे में जानेंगे।
अब आइए व्यावहारिक कार्यान्वयन देखें।
उदाहरण
import numpy as np
from matplotlib import pyplot
# initializing the images
img1 = np.array([np.array([100, 100]), np.array([80, 80])])
img2 = np.array([np.array([100, 100]), np.array([50, 0])])
img3 = np.array([np.array([100, 50]), np.array([100, 0])])
coordinates_horizontal = np.array([np.array([3, 3]), np.array([-3, -3])])
print(coordinates_horizontal, 'is a coordinates for detecting horizontal end points')
coordinates_vertical = np.array([np.array([3, -3]), np.array([3, - 3])])
print(coordinates_vertical, 'is a coordinates for detecting vertical end points')
#his will be an elemental multiplication followed by addition
def apply_coordinates(img, coordinates):
return np.sum(np.multiply(img, coordinates))
# Visualizing img1
pyplot.imshow(img1)
pyplot.axis('off')
pyplot.title('sample 1')
pyplot.show()
# Checking for horizontal and vertical features in image1
print('Horizontal end points features score:',
apply_coordinates(img1, coordinates_horizontal))
print('Vertical end points features score:',
apply_coordinates(img1,coordinates_vertical))
# Visualizing img2
pyplot.imshow(img2)
pyplot.axis('off')
pyplot.title('sample 2')
pyplot.show()
# Checking for horizontal and vertical features in image2
print('Horizontal end points features score:',
apply_coordinates(img2, coordinates_horizontal))
print('Vertical end points features score:',
apply_coordinates(img2, coordinates_vertical))
# Visualizing img3
pyplot.imshow(img3)
pyplot.axis('off')
pyplot.title('sample 3')
pyplot.show()
# Checking for horizontal and vertical features in image1
print('Horizontal end points features score:',
apply_coordinates(img3,coordinates_horizontal))
print('Vertical end points features score:',
apply_coordinates(img3,coordinates_vertical)) आउटपुट

निष्कर्ष
इस लेख में, हमने इंट्रोडक्शन-टू-कनवल्शन-यूजिंग-पायथन 3.x के बारे में सीखा। या इससे पहले और इसका क्रियान्वयन।