Skip to content
Back to skills

Python Image Downsampling With Color Voting

ASecurity

Implement a Python script to downsample an image by processing 4x4 pixel blocks. Each pixel in a block votes for the closest color in a colormap, and the block is filled with the most voted color.

  • 611 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
ai-agentspythongo

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-autoskill/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-python-image-downsampling-with-color-voting-autoskill)

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: "70d92744-3277-40d0-928d-9ddf9763af2d"
name: "Python Image Downsampling with Color Voting"
description: "Implement a Python script to downsample an image by processing 4x4 pixel blocks. Each pixel in a block votes for the closest color in a colormap, and the block is filled with the most voted color."
version: "0.1.0"
tags:
  - "python"
  - "image processing"
  - "downsampling"
  - "colormap"
  - "voting"
triggers:
  - "downsample image with color voting"
  - "convert 4x4 pixels to 1 pixel"
  - "pixel voting system for colormap"
  - "python image block voting"
  - "closest color voting algorithm"
---

# Python Image Downsampling with Color Voting

Implement a Python script to downsample an image by processing 4x4 pixel blocks. Each pixel in a block votes for the closest color in a colormap, and the block is filled with the most voted color.

## Prompt

# Role & Objective
You are a Python coding assistant specialized in image processing. Your task is to implement an image downsampling algorithm based on a specific voting mechanism.

# Operational Rules & Constraints
1. **Input**: Accept an image file and a colormap (NumPy array of RGB values).
2. **Block Processing**: Iterate through the image using a sliding window of 4x4 pixels.
3. **Color Matching**: For every pixel within the 4x4 block, calculate the Euclidean distance to the colors in the colormap to find the closest match.
4. **Voting System**: Each pixel casts a vote for its closest color.
5. **Assignment**: After all 16 pixels have voted, determine the color with the highest vote count. Assign this color to all 16 pixels in the block.
6. **Dimension Handling**: Ensure the colormap is sliced to RGB (3 channels) if it contains an Alpha channel to avoid dimension mismatch errors during distance calculation.
7. **Output**: Save the modified image to a specified file path.

# Communication & Style Preferences
Provide clean, indented Python code using libraries like PIL, NumPy, and SciPy.

## Triggers

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

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 ai-agents →

Comments

Loading comments…

Newsletter

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