[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-74246":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":13,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":15,"stars7d":16,"stars30d":17,"stars90d":14,"forks30d":14,"starsTrendScore":18,"compositeScore":19,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":20,"topics":23,"createdAt":9,"pushedAt":9,"updatedAt":24,"readmeContent":25,"aiSummary":26,"trendingCount":14,"starSnapshotCount":14,"syncStatus":13,"lastSyncTime":27,"discoverSource":28},74246,"perfectPixel","theamusing\u002FperfectPixel","theamusing","Refine and quantize messy AI pixel art into clean, perfect pixels.",null,"Python",1503,97,2,0,18,59,160,54,18.97,false,"main",true,[],"2026-06-12 02:03:24","# Perfect Pixel\n\n> **Auto detect and Get perfect Pixel art**\n\n![Python](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPython-3.8+-blue.svg)\n![License](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-MIT-green.svg)\n\n\u003Cimg src=\"https:\u002F\u002Fgithub.com\u002Ftheamusing\u002FperfectPixel\u002Fraw\u002Fmain\u002Fassets\u002Fprocess.png\" width=\"100%\" \u002F>\n\nStandard scaling often fails to sample AI-generated pixel art due to inconsistent sizes and non-square grids. \n\nThis tool automatically detects the optimal grid and delivers perfectly aligned, pixel-perfect results.\n\n## Features\n- Automatically detect grid size from pixel style images.\n- Refines AI generated pixel style image to perfectly aligned grids.\n- Easy to integrate into your own workflow.\n\n[Try the Web Demo](https:\u002F\u002Ftheamusing.github.io\u002FperfectPixel_webdemo\u002F)\n\n## Installation\n\n**Perfect Pixel** provides two implementations of the same core algorithm. The Lighweight Backend is designed in case you can't or don't want to use cv2. You can choose the one that best fits your environment:\n\n| Feature | OpenCV Backend ([`perfect_pixel.py`](.\u002Fsrc\u002Fperfect_pixel\u002Fperfect_pixel.py)) | Lightweight Backend ([`perfect_pixel_no_cv2.py`](.\u002Fsrc\u002Fperfect_pixel\u002Fperfect_pixel_noCV2.py)) |\n| :--- | :--- | :--- |\n| **Dependencies** | `opencv-python`, `numpy` | `numpy` |\n\nYou can install Perfect Pixel via `pip`. It is recommended to install the OpenCV version for better performance.\n\n```bash\n# Recommended: Fast version with OpenCV support\npip install perfect-pixel[opencv]\n\n# Numpy version: Lightweight (NumPy only)\npip install perfect-pixel\n```\n\n## ComfyUI\n\nA ComfyUI custom node is available for integrating Perfect Pixel into ComfyUI workflows.\n\n- No changes to the core Perfect Pixel algorithm\n- Provides a ComfyUI-friendly interface for pixel art refinement\n\n- [`Learn how to use Perfect Pixel as a ComfyUI node`](integrations\u002Fcomfyui\u002FREADME.md)\n\n## Usage \n\n### Step 1: Get pixel style image\nFirst you need extra tools to get a pixel styled image. **The recommanded size is between 512 to 1024.**\n\nYou can use Stable Diffusion with any Pixel Style Lora, or you can use ChatGPT or Gemini to generate one.\n\n\nFor example, I used ChatGPT to transfer an image into pixel style.\n\n```\nprompt: Convert the input image into a TRUE perler bead pixel pattern designed for physical bead crafting, not digital illustration. Canvas size must be exactly 32×32 pixels OR 16×16 pixels, where each pixel represents exactly one perler bead. Use extremely large, chunky pixels with very few active pixels overall. Simplicity is critical. Only keep the main subject. Remove the entire background. For human characters, make sure the face is flat and no shadow. The subject must be centered with clear empty bead rows around all edges to allow easy mounting on a bead board. Add a clean, continuous dark outline around the subject so the silhouette is clearly readable when made with beads. Use a very limited solid color palette (maximum 6–8 colors total). No gradients, no shading, no lighting, no dithering, no texture. No anti-aliasing or smoothing — every pixel must be a perfect square bead aligned to the grid. The output image should be pixel-perfect, each grid only contains one color. Background must be pure solid white.\n```\n\n\u003Cimg src=\"https:\u002F\u002Fgithub.com\u002Ftheamusing\u002FperfectPixel\u002Fraw\u002Fmain\u002Fassets\u002Fgenerated.png\" width=\"50%\" \u002F>\n\nThe image is in pixel style but the grids are distorted. Also we don't know the number of grids.\n\n### Step 2: Use Perfect Pixel to refine your image\n\n```python\nimport cv2\nfrom perfect_pixel import get_perfect_pixel\n\nbgr = cv2.imread(\"images\u002Favatar.png\", cv2.IMREAD_COLOR)\nrgb = cv2.cvtColor(bgr, cv2.COLOR_BGR2RGB)\n\nw, h, out = get_perfect_pixel(rgb)\n```\n\n\u003Cimg src=\"https:\u002F\u002Fgithub.com\u002Ftheamusing\u002FperfectPixel\u002Fraw\u002Fmain\u002Fassets\u002Frefined2.png\" width=\"50%\" \u002F>\n\n*Also see [example.py](.\u002Fexample.py).*\n```bash\npython example.py\n```\n\nThe grid size is automatically detected, and the image is refined.\n\n\u003Cimg src=\"https:\u002F\u002Fgithub.com\u002Ftheamusing\u002FperfectPixel\u002Fraw\u002Fmain\u002Fassets\u002Fprocess2.png\" width=\"100%\" \u002F>\n\nTry integrate it into your own projects!\n\n## API Reference\n| Args | Description | \n| :--- | :--- |\n| **image** | `RGB Image (H * W * 3)` |\n| **sample_method** | `\"center\", \"median\" or \"majority\"` |\n| **grid_size** | `Manually set grid size (grid_w, grid_h) to override auto-detection` |\n| **min_size** | `Minimum pixel size to consider valid` |\n| **peak_width** | `Minimum peak width for peak detection.` |\n| **refine_intensity** | `Intensity for grid line refinement. Recommended range is [0, 0.5]. Given original estimated grid line at x, the refinement will search in [x * (1 - refine_intensity), x * (1 + refine_intensity)].` |\n| **fix_square** | `Whether to enforce output to be square when detected image is almost square.` |\n| **debug** | `Whether to show debug plots.` |\n\n| Returns | Description |\n| :--- | :--- |\n| **refined_w** | `Width of the refined image` |\n| **refined_h** | `Height of the refined image` |\n| **scaled_image** | `Refined Image(W * H * 3)` |\n\n## Algorithm\n\n\u003Cimg src=\"https:\u002F\u002Fgithub.com\u002Ftheamusing\u002FperfectPixel\u002Fraw\u002Fmain\u002Fassets\u002Falgorithm.png\" width=\"100%\" \u002F>\n\nThe whole algorithm mainly contains 3 steps:\n1. Detect grid size from FFT magnitude of the original image and generate grids.\n2. Detect edges using Sobel and refine the grids by aligning them to edges.\n3. Use the grids to sample the original image and to get the scaled image.\n\n## Star History\n\n[![Star History Chart](https:\u002F\u002Fapi.star-history.com\u002Fsvg?repos=theamusing\u002FperfectPixel&type=date&legend=top-left)](https:\u002F\u002Fwww.star-history.com\u002F#theamusing\u002FperfectPixel&type=date&legend=top-left)\n\nThanks so much!\n\n\n\n\n\n\n\n\n\n","Perfect Pixel 是一个用于优化和量化杂乱的AI像素艺术，使其变得干净、完美的工具。它能够自动检测最佳网格大小，并将AI生成的像素风格图像调整为完美对齐的网格，从而解决标准缩放方法因尺寸不一致和非方形网格导致的问题。项目使用Python编写，提供了基于OpenCV和仅依赖NumPy两种实现方式以适应不同环境需求。适用于需要高质量像素艺术的场景，如游戏开发、数字艺术创作或任何希望提升像素图像质量的情况。通过简单的安装步骤即可轻松集成到现有工作流程中，同时支持ComfyUI定制节点以进一步扩展其应用范围。","2026-06-11 03:49:39","high_star"]