Image Convert Grayscale¶
Class: ConvertGrayscaleBlockV1
Source: inference.core.workflows.core_steps.classical_cv.convert_grayscale.v1.ConvertGrayscaleBlockV1
Convert color (RGB/BGR) images to single-channel grayscale images using weighted luminance conversion to reduce dimensionality, prepare images for operations that require grayscale input (thresholding, morphological operations, contour detection), reduce computational complexity, and enable intensity-based image analysis and processing workflows.
How This Block Works¶
This block converts color images to grayscale images by combining the color channels into a single intensity channel. The block:
- Receives a color input image (RGB or BGR format with three color channels)
- Applies weighted luminance conversion using OpenCV's BGR to grayscale algorithm:
- Uses the standard formula: Grayscale = 0.299R + 0.587G + 0.114*B (for RGB) or weighted BGR combination
- Weights green channel most heavily (58.7%) as human eye is most sensitive to green
- Weights red channel moderately (29.9%) and blue channel least (11.4%)
- Creates a perceptually balanced grayscale representation that preserves visual information
- Converts the three-channel color image to a single-channel grayscale image:
- Reduces image from 3 channels (RGB/BGR) to 1 channel (grayscale)
- Each pixel becomes a single intensity value between 0 (black) and 255 (white)
- Preserves spatial information while removing color information
- Reduces memory usage and computational complexity
- Preserves image dimensions (width and height remain the same)
- Maintains image metadata and structure
- Returns the single-channel grayscale image
Grayscale conversion transforms color images into intensity-only images where each pixel represents brightness rather than color. The weighted luminance formula ensures the grayscale image perceptually matches the brightness distribution of the original color image. This conversion is essential for many computer vision operations that require single-channel input, such as thresholding, morphological transformations, edge detection, and contour analysis. The output retains spatial information and intensity relationships while removing color information, enabling intensity-based processing and analysis.
Common Use Cases¶
- Preprocessing for Thresholding: Convert color images to grayscale before applying thresholding operations (e.g., prepare images for binary thresholding, convert before adaptive thresholding, grayscale before Otsu's method), enabling color-to-threshold workflows
- Morphological Operations: Prepare color images for morphological transformations that require grayscale input (e.g., convert before erosion/dilation, grayscale for opening/closing, prepare for morphological operations), enabling color-to-morphology workflows
- Contour Detection: Convert color images to grayscale before contour detection and shape analysis (e.g., prepare for contour detection, convert before shape analysis, grayscale for boundary extraction), enabling color-to-contour workflows
- Edge Detection: Prepare color images for edge detection algorithms that work on grayscale images (e.g., convert before Canny edge detection, grayscale for Sobel operators, prepare for edge detection), enabling color-to-edge workflows
- Noise Reduction: Reduce dimensionality for noise reduction operations that work on single-channel images (e.g., convert before filtering, grayscale for denoising, prepare for noise reduction), enabling color-to-filtering workflows
- Feature Extraction: Convert color images to grayscale for intensity-based feature extraction (e.g., prepare for SIFT/keypoint detection, convert for texture analysis, grayscale for pattern recognition), enabling color-to-feature workflows
Connecting to Other Blocks¶
This block receives a color image and produces a grayscale image:
- Before threshold blocks to convert color images to grayscale before thresholding (e.g., convert color to grayscale then threshold, prepare color images for binarization, grayscale before binary conversion), enabling color-to-threshold workflows
- Before morphological transformation blocks to prepare color images for morphological operations (e.g., convert color to grayscale for morphology, prepare for erosion/dilation, grayscale before morphological operations), enabling color-to-morphology workflows
- Before contour detection blocks to convert color images to grayscale before contour detection (e.g., convert color to grayscale for contours, prepare color images for shape analysis, grayscale before contour detection), enabling color-to-contour workflows
- Before classical CV blocks that require grayscale input (e.g., prepare for edge detection, convert for feature extraction, grayscale for classical computer vision operations), enabling color-to-classical-CV workflows
- After image preprocessing blocks that output color images (e.g., convert preprocessed color images to grayscale, grayscale after color enhancements, convert after color transformations), enabling preprocessing-to-grayscale workflows
- In image processing pipelines where grayscale conversion is required for downstream processing (e.g., convert color to grayscale in pipelines, prepare images for single-channel operations, reduce dimensionality for processing), enabling grayscale conversion pipeline workflows
Requirements¶
This block works on color images (RGB or BGR format with three color channels). The input image must have multiple color channels. If the input is already grayscale, the conversion will still be applied but will result in the same grayscale output. The conversion uses standard luminance weighting to create perceptually balanced grayscale images that preserve brightness information while removing color information.
Type identifier¶
Use the following identifier in step "type" field: roboflow_core/convert_grayscale@v1to add the block as
as step in your workflow.
Properties¶
| Name | Type | Description | Refs |
|---|---|---|---|
name |
str |
Enter a unique identifier for this step.. | ❌ |
The Refs column marks possibility to parametrise the property with dynamic values available
in workflow runtime. See Bindings for more info.
Available Connections¶
Compatible Blocks
Check what blocks you can connect to Image Convert Grayscale in version v1.
- inputs:
Perspective Correction,Stability AI Inpainting,Image Convert Grayscale,Morphological Transformation,Pixelate Visualization,Stitch Images,QR Code Generator,Image Slicer,Image Preprocessing,SIFT,Line Counter Visualization,Polygon Zone Visualization,Image Threshold,Image Slicer,Corner Visualization,Dynamic Crop,Stability AI Outpainting,Halo Visualization,Heatmap Visualization,Keypoint Visualization,Color Visualization,Blur Visualization,Stability AI Image Generation,Camera Focus,Label Visualization,Classification Label Visualization,Camera Focus,Camera Calibration,Morphological Transformation,Trace Visualization,Contrast Enhancement,Bounding Box Visualization,Reference Path Visualization,Depth Estimation,Halo Visualization,Ellipse Visualization,Model Comparison Visualization,Dot Visualization,SIFT Comparison,Image Contours,Mask Visualization,Relative Static Crop,Crop Visualization,Background Subtraction,Circle Visualization,Text Display,Polygon Visualization,Background Color Visualization,Absolute Static Crop,Image Blur,Polygon Visualization,Contrast Equalization,Grid Visualization,Icon Visualization,Triangle Visualization - outputs:
Keypoint Detection Model,Clip Comparison,Morphological Transformation,SAM 3,Qwen-VL,VLM As Detector,Email Notification,Twilio SMS/MMS Notification,YOLO-World Model,MoonshotAI Kimi,Polygon Zone Visualization,OpenAI,VLM As Detector,Heatmap Visualization,Keypoint Visualization,Llama 3.2 Vision,Anthropic Claude,Stability AI Image Generation,Google Vision OCR,Seg Preview,Camera Focus,Label Visualization,SAM 3,Instance Segmentation Model,Qwen3.5,Multi-Label Classification Model,SmolVLM2,Google Gemini,Motion Detection,Background Color Visualization,Mask Edge Snap,Instance Segmentation Model,Qwen 3.5 API,Google Gemini,Polygon Visualization,Moondream2,SIFT Comparison,Florence-2 Model,Barcode Detection,Time in Zone,Single-Label Classification Model,OCR Model,VLM As Classifier,Qwen2.5-VL,Detections Stabilizer,LMM For Classification,Keypoint Detection Model,SIFT,Image Preprocessing,Roboflow Dataset Upload,Corner Visualization,Stability AI Outpainting,Segment Anything 2 Model,Multi-Label Classification Model,Halo Visualization,Qwen3-VL,Qwen3.5-VL,Semantic Segmentation Model,Blur Visualization,Perception Encoder Embedding Model,Morphological Transformation,Trace Visualization,VLM As Classifier,Gaze Detection,Reference Path Visualization,Halo Visualization,Model Comparison Visualization,Dot Visualization,Pixel Color Count,Background Subtraction,QR Code Detection,Text Display,ByteTrack Tracker,Absolute Static Crop,Florence-2 Model,Byte Tracker,Icon Visualization,Object Detection Model,Perspective Correction,SAM 3,BoT-SORT Tracker,Stability AI Inpainting,Image Convert Grayscale,Object Detection Model,OpenRouter,OpenAI,Llama 3.2 Vision,Image Threshold,OC-SORT Tracker,Anthropic Claude,Dynamic Crop,Clip Comparison,Dominant Color,Contrast Enhancement,Bounding Box Visualization,Depth Estimation,Keypoint Detection Model,CLIP Embedding Model,Image Contours,EasyOCR,Relative Static Crop,Multi-Label Classification Model,Polygon Visualization,Google Gemma API,Qwen 3.6 API,Template Matching,Single-Label Classification Model,Image Blur,Anthropic Claude,Triangle Visualization,Object Detection Model,OpenAI,Image Stack,Pixelate Visualization,Single-Label Classification Model,OpenAI,Instance Segmentation Model,Buffer,Stitch Images,Image Slicer,Line Counter Visualization,Image Slicer,Semantic Segmentation Model,LMM,Roboflow Dataset Upload,Color Visualization,Google Gemini,Classification Label Visualization,Camera Focus,Camera Calibration,Detections Stitch,Ellipse Visualization,SORT Tracker,Mask Visualization,GLM-OCR,Crop Visualization,Circle Visualization,CogVLM,SAM2 Video Tracker,Contrast Equalization,Roboflow Vision Events,MoonshotAI Kimi,Google Gemma
Input and Output Bindings¶
The available connections depend on its binding kinds. Check what binding kinds
Image Convert Grayscale in version v1 has.
Bindings
-
input
image(image): Input color image (RGB or BGR format with three color channels) to convert to grayscale. The image will be converted from three-channel color (RGB/BGR) to single-channel grayscale using weighted luminance conversion (weights: green 58.7%, red 29.9%, blue 11.4%) to create a perceptually balanced grayscale representation. The output will have the same width and height but only one channel (grayscale intensity values 0-255). Original image metadata and spatial dimensions are preserved. If the input is already grayscale, the conversion will still be applied but will result in the same grayscale output. Use this block before operations that require grayscale input such as thresholding, morphological operations, contour detection, or edge detection..
-
output
image(image): Image in workflows.
Example JSON definition of step Image Convert Grayscale in version v1
{
"name": "<your_step_name_here>",
"type": "roboflow_core/convert_grayscale@v1",
"image": "$inputs.image"
}