Skip to main content

Posts

Showing posts from May, 2021

how to convert an image to Grey scale using the opencv4nodejs package in Hindi | opencv rgb to grey | bgr to grey opencv |  opencv node imread

इस tutorial में हम सीखेंगे कि opencv4nodejs पैकेज का उपयोग करके किसी image को grey scale में कैसे convert किया जाए। Image को grey scale में कैसे convert करें OpenCV के किसी भी function का उपयोग करने के लिए सबसे पहले हमें  opencv4nodejs module को load करना पड़ेगा। निचे दी हुई लाइन OpenCV को load करेगी।   const cv = require('opencv4nodejs'); एक बार OpenCV लोड करने के बाद हम उस इमेज को read करेंगे जिसे हम grey scale में convert करना चाहते है। OpenCV इस्तेमाल करने के लिए आपको cv इस keyword को इस्तेमाल करना पड़ेगा, जो original photo को read करने के लिए और इसे greyscale में परिवर्तित करने के लिए आवश्यक चीजे उपलब्ध कराएगा। original photo को read करने के लिए, बस cv मॉड्यूल के imread() function को कॉल करें, image path को string के रूप में इस्तेमाल करें। var image = cv.imread('C:/Users/Admin/Desktop/photo.jpg') अब अगला स्टेप है, इस image को greyscale mode में convert करना। इसके लिए हमें OpenCv का bgrToGray function इस्तेमाल करना पड़ेगा, जो हमें साधारण रंगीन imag