agentsclimarketplace

Python image downsampling with color voting

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/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.From its SKILL.md

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

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.1 KB, 336 tokens by cl100k_base, as published. Nobody here has run it

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

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.