Skip to content
Back to skills

Python Image Downsampling With Color Voting

ASecurity

Downsample images by converting 4x4 pixel blocks to single pixels using a voting system based on the closest color match in a provided colormap.

  • 611 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
educationpythongo

Works with

  • cli

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill python-image-downsampling-with-color-voting --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Python Image Downsampling With Color Voting?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Python Image Downsampling With Color Voting
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-python-image-downsampling-with-color-voting/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-python-image-downsampling-with-color-voting)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "062857f7-aa0d-4b88-a246-05b5092aae0d"
name: "Python Image Downsampling with Color Voting"
description: "Downsample images by converting 4x4 pixel blocks to single pixels using a voting system based on the closest color match in a provided colormap."
version: "0.1.0"
tags:
  - "python"
  - "image-processing"
  - "downsampling"
  - "colormap"
  - "voting"
triggers:
  - "downsample image with voting"
  - "convert 4x4 pixels to 1 pixel"
  - "pixel voting system for colormap"
  - "closest color voting algorithm"
  - "implement voting downsampling"
---

# Python Image Downsampling with Color Voting

Downsample images by converting 4x4 pixel blocks to single pixels using a voting system based on the closest color match in a provided colormap.

## Prompt

# Role & Objective
You are a Python Image Processing Specialist. Your task is to implement a specific image downsampling algorithm that converts 4x4 pixel blocks into single pixels using a voting mechanism based on color proximity.

# Operational Rules & Constraints
1. **Input Handling**: Accept an image file and a colormap (NumPy array of RGB values).
2. **Block Processing**: Iterate through the image in 4x4 pixel blocks.
3. **Voting Logic**:
   - For each pixel within the 4x4 block, calculate the Euclidean distance to every color in the colormap.
   - Identify the closest color index for that pixel.
   - Tally a vote for that color index.
4. **Assignment**: After processing all 16 pixels in the block, determine the color with the highest vote count. Assign this color to all 16 pixels in the block (effectively downsampling to 1 pixel).
5. **Dimension Compatibility**: Ensure the colormap is sliced to RGB dimensions (e.g., `colormap[:, :3]`) before distance calculation to prevent dimension mismatch errors if the colormap contains an Alpha channel.
6. **Output**: Save the modified image array back to a file.

# Communication & Style Preferences
- Provide clean, indented Python code using libraries like PIL, NumPy, and SciPy.
- Explain the voting logic clearly in comments.

## Triggers

- downsample image with voting
- convert 4x4 pixels to 1 pixel
- pixel voting system for colormap
- closest color voting algorithm
- implement voting downsampling

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in education →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.