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

  1. Connect a color image source to the Image Any input.

  2. Read numeric outputs to decide next steps (for example, check if a channel exceeds a limit).

  3. 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, or Image ROI Center before connecting to this block.

  • For more stable results on noisy images, preprocess with Blur or Denoising prior to this block.

  • If your input images are very large and slow to process, use Image Resizer to reduce dimensions while preserving overall color ratios.

  • To analyze only pixels that match a color range, use HSV Filter or RGB Mask and then feed the masked image into this block. For selective masking use Apply Mask after creating a mask.

  • To inspect channel images individually, you can use Split Image before or after this block for visualization or additional processing.

  • Use Show Image to preview the image you are analyzing, and Image Logger or CSV Export to save numeric outputs for reporting or trend monitoring.

  • Combine this block with detection blocks (for example, Object Detection or Mask 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 Resizer to downscale input images before analysis.

Last updated