Color Density Percentage
This function block computes how much each color channel (Red, Green, Blue) contributes to the overall intensity of a color image. It is useful for quick color analysis, quality checks, and preprocessing decisions in vision pipelines.
π₯ Inputs
Image Any
3-channel color image (RGB or BGR). The block expects a regular color image to calculate per-channel totals and percentages.
π€ Outputs
Red Percentage
Percentage of red intensity relative to the total image intensity (0β100, rounded).
Red Total
Sum of red channel intensity values (absolute total).
Green Percentage
Percentage of green intensity relative to the total image intensity (0β100, rounded).
Green Total
Sum of green channel intensity values (absolute total).
Blue Percentage
Percentage of blue intensity relative to the total image intensity (0β100, rounded).
Blue Total
Sum of blue channel intensity values (absolute total).
πΉοΈ Controls
This function block has no interactive widgets. Provide the image through the input socket to run the calculation.
βοΈ Running mechanism
When the block receives a 3-channel image it sums intensities of each color channel and the combined intensity per pixel.
Channel percentages are calculated as channel_sum / total_sum and then scaled to percent.
Totals and percentages are output as numeric values (percentages are rounded for readability).
If the input is not a valid 3-channel image the block will indicate an invalid input (check your upstream blocks).
π― Key features
Quick per-image color composition summary (percentages + raw totals).
Works on standard RGB/BGR images without extra configuration.
Outputs are numeric and easy to log, visualize or use in decision logic.
π Usage instructions
Connect a color image source to the
Image Anyinput.Read numeric outputs to decide next steps (for example, check if a channel exceeds a limit).
Use outputs with logging or visualization blocks to track changes over time.
π‘ Tips and Tricks
To focus the analysis on a specific area, crop the image first using
Image ROI,Image ROI Select, orImage ROI Centerbefore connecting to this block.For more stable results on noisy images, preprocess with
BlurorDenoisingprior to this block.If your input images are very large and slow to process, use
Image Resizerto reduce dimensions while preserving overall color ratios.To analyze only pixels that match a color range, use
HSV FilterorRGB Maskand then feed the masked image into this block. For selective masking useApply Maskafter creating a mask.To inspect channel images individually, you can use
Split Imagebefore or after this block for visualization or additional processing.Use
Show Imageto preview the image you are analyzing, andImage LoggerorCSV Exportto save numeric outputs for reporting or trend monitoring.Combine this block with detection blocks (for example,
Object DetectionorMask Detection) to compute color statistics only for detected objects or regions.
(Hint: all recommended blocks above are available in the block collection and can be combined directly in the visual editor.)
π οΈ Troubleshooting
If outputs look incorrect, verify the upstream image is a 3-channel color image.
If percentages sum to unexpected values, ensure the image is not pre-normalized or converted to a single channel before this block.
If processing is slow, insert an
Image Resizerto downscale input images before analysis.
Last updated