Grayscale Image

OpenCV in Hindi – Grayscale Image

Python OpenCV

OpenCV Grayscale image in hindi – OpenCV Ke Kuch Method Ka Use Kar Ke Aap Kisi Bhi Image Ko Color Image Se Grayscale Image Me Convert Kar Sakte Hai. Gray Coloured Shade Wale Images Ko Hi Grayscale Images Kahte Hai.

Agar Aap OpenCV Ko Poora A-Z Learn Karna Chahte Hai To Aapko, Sabse Pahle Aapko OpenCV Ke Previous Post Ko Read Karna Chahiye – OpenCV – Image Size

OpenCV – Grayscale image in hindi

Opencv Me Kisi Image Ko Grayscale Image Me Convert Karne Ke Liye Ek Se Jyada Tricks Hai. Below Humne 2 Example Me Full Explain Kiya Hai, Convert Color Image To Grayscale Image In Hindi.

Normally Hum Jinhe Black&White Image Bolte Hai Wo Grayscale Image Ka Example Hai.

Example No 1

import cv2
img = cv2.imread('model.jpg')

cv2.imshow("Original Image",img)
gray_img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

cv2.imshow("Gray Image",gray_img)

cv2.waitKey(0)
cv2.destroyAllWindows()

Output

Example 1 Output

STEP 1 = Sabse Pahle cv2 Ko import Kiya

STEP 2 = img Variable Banaya Phir cv2.imread Method Ka Use Kar Ke model.jpg Ko Read Kiya.

STEP 3 = cv2.imshow Ka Use Kar Ke Original image Ko Show Karenge.

STEP 4 = cv2.imshow Me First Parameter Me Ek string Pass Karenge And Second Parameter Me img Ko Pass Karenge.

STEP 5 = gray_img Name Ka Ek Variable Banaya Usme cv2.cvtColor Method Ka Use Kiya, First Parameter Me img Ko Pass kiya And Second Parameter Me COLOR_BGR2GRAY Ko Pass Kiya.

STEP 6 = cv2.imshow Me First Parameter Me Ek string Pass Karenge And Second Parameter Me gray_img Ko Pass Karenge.

STEP 7 = cv2.waitkey(0) Iska Use Karne Se Ek Window Show Hoga, Jisme Aapka Image Show Hoga Aur Wo Hold Position Me Rahega. Ko Parameter Me Dene Se Ye Close Nahi Hoga.

STEP 8 = cv2.destroyAllWindows() Iske Use Karke Program Me Running Sabhi Codes Ko Memory Se Release Kiya Jata Hai And Program Stop Ho Jata Hai.

Example No 2

Kisi Image Ko Grayscale Image Me Convert Karne Ka Ye Step Sabse Easy Hai. Professionals Programmers Is Trick Ko Follow Karte Hai.

import cv2

img = cv2.imread('master.jpg',0)

cv2.imshow("Gray Image",img)

cv2.waitKey(0)
cv2.destroyAllWindows()

Output

Grayscale Image of master.jpg

STEP 1 = Sabse Pahle cv2 Ko import Kiya

STEP 2 = img Variable Banaya And cv2.imread Method Ka Use Kiya.

STEP 3 = img Variable Ke Function Me First Parameter Me master.jpg Ko Pass Kiya And Second Variable Me 0 Ko Pass Kiya.

STEP 4 = Second Parameter Me (0) GrayScale Images Me Convert Karne Ke Liye Kiya Jata Hai.

STEP 5 = cv2.waitkey(0) Iska Use Karne Se Ek Window Show Hoga, Jisme Aapka Image Show Hoga Aur Wo Hold Position Me Rahega. Ko Parameter Me Dene Se Ye Close Nahi Hoga.

STEP 6 = cv2.destroyAllWindows() Iske Use Karke Program Me Running Sabhi Codes Ko Memory Se Release Kiya Jata Hai And Program Stop Ho Jata Hai.

Friends Mujhe Umeed Hai Ki Aapko OpenCV In Hindi Ke Bare Mai 100% Jankari Ho Gayi Hogi | Agar Aapko Learn Karne Main Dikkat Aa Rahi Hai To Aap Mere Se Contact Kar Sakte Hai |

Leave a Reply

Your email address will not be published. Required fields are marked *