Grayscale conversion
Convert RGB images to grayscale using OpenCV (cv2) in Python. Use this skill when the user needs to convert color images to grayscale for image processing, template matching, or analysis.From its SKILL.md
npx -y skills add cxcscmu/SkillLearnBench --skill grayscale-conversionAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
0.9 KB, 189 tokens by cl100k_base, as published. Nobody here has run it
Grayscale Image Conversion
Convert RGB/BGR images to grayscale using OpenCV.
Python Code
import cv2
img = cv2.imread("input.png")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.imwrite("input.png", gray) # overwrite in-place
Batch Conversion
import cv2
import glob
for path in sorted(glob.glob("/root/keyframes_*.png")):
img = cv2.imread(path)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.imwrite(path, gray)
Notes
- OpenCV reads images in BGR format, so use
COLOR_BGR2GRAY - Writing a grayscale image back with
cv2.imwriteproduces a single-channel PNG - Grayscale conversion is often a prerequisite for template matching with
cv2.matchTemplate
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.