@xprite/pixelate 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +72 -40
  2. package/README.zh-CN.md +65 -34
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -5,23 +5,33 @@
5
5
 
6
6
  English | [简体中文](https://github.com/rhinoc/xprite-pixelate/blob/main/README.zh-CN.md)
7
7
 
8
- | AI-generated, 887×887 | Recovered grid | Real pixel art, 48×49 |
9
- | :---: | :---: | :---: |
10
- | ![Input](docs/images/griffith-input.png) | ![Grid](docs/images/griffith-mesh.png) | ![Result](docs/images/griffith-result.png) |
8
+ Recover the real pixel grid of AI-generated pixel art and get back one clean pixel per cell. It
9
+ also turns ordinary images into pixel art. It runs in browsers and Node, has no runtime
10
+ dependencies, and is the importer of the [Xprite](https://xprite.cc) pixel editor.
11
11
 
12
- ## Summary
12
+ ## Compared with other tools
13
+
14
+ A real generated image (887×887, cells 15 to 21 px wide), recovered by each tool with its default
15
+ settings. Xprite puts each cut on a colour edge, so it does not cut through the eye, the boots or
16
+ the sword.
13
17
 
14
- Image generators draw "pixel art" with soft edges, noise, half-transparent outlines and cells of
15
- uneven width. This package finds the real pixel grid in such an image and gives back one clean
16
- pixel per cell. It also turns ordinary images into pixel art.
18
+ | Recovered grid | Xprite, 48×49 | [pixel-art-fixer](https://github.com/Retro-Diffusion/pixel-art-fixer), 47×48 | [perfectPixel](https://github.com/theamusing/perfectPixel), 50×50 | [proper-pixel-art](https://github.com/KennethJAllen/proper-pixel-art), 53×54 |
19
+ | :---: | :---: | :---: | :---: | :---: |
20
+ | ![Grid](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/griffith-mesh.png) | ![Xprite](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/griffith-xprite.png) | ![pixel-art-fixer](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/griffith-fixer.png) | ![perfectPixel](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/griffith-perfectpixel.png) | ![proper-pixel-art](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/griffith-proper.png) |
17
21
 
18
- It runs in browsers and Node and has no runtime dependencies. One WebAssembly module ships inside
19
- the package. It is the importer of the [Xprite](https://xprite.cc) pixel editor.
22
+ On the AI suite of [our benchmark](#benchmark) (1746 cases), Xprite gets the exact size most
23
+ often:
24
+
25
+ | Method | Exact size | Within 1 cell | Pixel match | Half-transparent fringe | Median time |
26
+ | --- | --- | --- | --- | --- | --- |
27
+ | Xprite Auto | **83.6%** | **90.0%** | **99.8%** | 0.1% | 1.55 s |
28
+ | pixel-art-fixer | 49.7% | 80.9% | 98.3% | 0.0% | 0.18 s |
29
+ | perfectPixel | 53.3% | 68.0% | 96.7% | - | 0.03 s |
30
+ | proper-pixel-art | 72.2% | 80.4% | 99.7% | 0.0% | 0.49 s |
20
31
 
21
32
  ## Contents
22
33
 
23
34
  - [Examples](#examples)
24
- - [Compared with other tools](#compared-with-other-tools)
25
35
  - [Install](#install)
26
36
  - [Usage](#usage)
27
37
  - [How it works](#how-it-works)
@@ -30,52 +40,57 @@ the package. It is the importer of the [Xprite](https://xprite.cc) pixel editor.
30
40
 
31
41
  ## Examples
32
42
 
33
- These inputs come from the benchmark's AI suite: CC0 pixel art rendered the way generators fake
34
- it. Each result has exactly the size of the original art.
43
+ Each example is one case from a category of the benchmark's AI suite: CC0 pixel art rendered the
44
+ way generators fake it, with a known native size. The sizes are the visible art in cells; ✓ marks
45
+ the exact native size. Every tool runs with its default settings.
35
46
 
36
47
  ### Two sprites on one canvas
37
48
 
38
- - Goblins by LuizMelo ([Monsters Creatures Fantasy](https://luizmelo.itch.io/monsters-creatures-fantasy), CC0)
49
+ - [Goblins by LuizMelo](https://luizmelo.itch.io/monsters-creatures-fantasy), CC0. Category `gen_pair`. Native art: 78×36.
39
50
 
40
- | Input, 1800×845 | Recovered grid | Result, 103×49 |
41
- | :---: | :---: | :---: |
42
- | ![Input](docs/images/goblins-input.png) | ![Grid](docs/images/goblins-mesh.png) | ![Result](docs/images/goblins-result.png) |
51
+ | Input, 1800×845 | Xprite, 78×36 ✓ | pixel-art-fixer, 78×35 ✗ | perfectPixel, 80×36 ✗ | proper-pixel-art, 79×36 ✗ |
52
+ | :---: | :---: | :---: | :---: | :---: |
53
+ | ![Input, 1800×845](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/pair-input.png) | ![Xprite](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/pair-xprite.png) | ![pixel-art-fixer](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/pair-fixer.png) | ![perfectPixel](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/pair-perfectpixel.png) | ![proper-pixel-art](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/pair-proper.png) |
43
54
 
44
- ### Painterly shading inside cells
55
+ ### Cells that drift and jitter
45
56
 
46
- - Naga mage from [Dungeon Crawl Stone Soup tiles](https://github.com/crawl/tiles) (CC0)
57
+ - [Boss dragon by ansimuz](https://opengameart.org/content/sideview-fantasy-patreon-collection), CC0. Category `gen_wobble`. Native art: 71×39.
47
58
 
48
- | Input, 411×425 | Recovered grid | Result, 50×50 |
49
- | :---: | :---: | :---: |
50
- | ![Input](docs/images/naga-input.png) | ![Grid](docs/images/naga-mesh.png) | ![Result](docs/images/naga-result.png) |
59
+ | Input, 1226×664 | Xprite, 71×39 ✓ | pixel-art-fixer, 69×38 ✗ | perfectPixel, 74×39 ✗ | proper-pixel-art, 69×38 ✗ |
60
+ | :---: | :---: | :---: | :---: | :---: |
61
+ | ![Input, 1226×664](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/wobble-input.png) | ![Xprite](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/wobble-xprite.png) | ![pixel-art-fixer](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/wobble-fixer.png) | ![perfectPixel](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/wobble-perfectpixel.png) | ![proper-pixel-art](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/wobble-proper.png) |
51
62
 
52
- ### Cells that drift and jitter
63
+ ### Small cells and WebP damage
53
64
 
54
- - Monster by Denzi ([Denzi's public domain art](https://opengameart.org/content/denzis-public-domain-art), CC0)
65
+ - [Monster by Denzi](https://opengameart.org/content/denzis-public-domain-art), CC0. Category `gen_small_pitch`. Native art: 32×48.
55
66
 
56
- | Input, 606×924 | Recovered grid | Result, 45×67 |
57
- | :---: | :---: | :---: |
58
- | ![Input](docs/images/wobble-input.png) | ![Grid](docs/images/wobble-mesh.png) | ![Result](docs/images/wobble-result.png) |
67
+ | Input, 218×339 | Xprite, 32×48 ✓ | pixel-art-fixer, 32×47 ✗ | perfectPixel, 32×49 ✗ | proper-pixel-art, 34×49 ✗ |
68
+ | :---: | :---: | :---: | :---: | :---: |
69
+ | ![Input, 218×339](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/small-input.png) | ![Xprite](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/small-xprite.png) | ![pixel-art-fixer](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/small-fixer.png) | ![perfectPixel](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/small-perfectpixel.png) | ![proper-pixel-art](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/small-proper.png) |
59
70
 
60
- ### Small cells and WebP damage
71
+ ### A small sprite on a large clear canvas
61
72
 
62
- - Old man by ansimuz ([Gothicvania Town](https://opengameart.org/content/gothicvania-town), CC0)
73
+ - [Nekomimi girl by cawfeecrow](https://opengameart.org/content/nekomimi-girl-portrait), CC0. Category `gen_sparse`. Native art: 123×136.
63
74
 
64
- | Input, 250×380 | Recovered grid | Result, 39×57 |
65
- | :---: | :---: | :---: |
66
- | ![Input](docs/images/oldman-input.png) | ![Grid](docs/images/oldman-mesh.png) | ![Result](docs/images/oldman-result.png) |
75
+ | Input, 1797×1800 | Xprite, 123×136 ✓ | pixel-art-fixer, 122×136 ✗ | perfectPixel, 124×136 ✗ | proper-pixel-art, 127×142 ✗ |
76
+ | :---: | :---: | :---: | :---: | :---: |
77
+ | ![Input, 1797×1800](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/sparse-input.png) | ![Xprite](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/sparse-xprite.png) | ![pixel-art-fixer](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/sparse-fixer.png) | ![perfectPixel](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/sparse-perfectpixel.png) | ![proper-pixel-art](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/sparse-proper.png) |
67
78
 
68
- ## Compared with other tools
79
+ ### An off-white background
69
80
 
70
- The image at the top, recovered by each tool with its default settings:
81
+ - [Dragon by ansimuz](https://opengameart.org/content/sideview-fantasy-patreon-collection), CC0. Category `gen_white`. Native art: 162×106.
71
82
 
72
- | Xprite Auto, 48×49 | [pixel-art-fixer](https://github.com/Retro-Diffusion/pixel-art-fixer), 47×48 | [perfectPixel](https://github.com/theamusing/perfectPixel), 50×50 | [proper-pixel-art](https://github.com/KennethJAllen/proper-pixel-art), 53×54 |
73
- | :---: | :---: | :---: | :---: |
74
- | ![Xprite](docs/images/griffith-result.png) | ![pixel-art-fixer](docs/images/griffith-fixer.png) | ![perfectPixel](docs/images/griffith-perfectpixel.png) | ![proper-pixel-art](docs/images/griffith-proper.png) |
83
+ | Input, 1800×1210 | Xprite, 162×106 ✓ | pixel-art-fixer, 325×208 ✗ | perfectPixel, 161×105 ✗ | proper-pixel-art, 168×106 ✗ |
84
+ | :---: | :---: | :---: | :---: | :---: |
85
+ | ![Input, 1800×1210](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/white-input.png) | ![Xprite](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/white-xprite.png) | ![pixel-art-fixer](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/white-fixer.png) | ![perfectPixel](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/white-perfectpixel.png) | ![proper-pixel-art](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/white-proper.png) |
75
86
 
76
- The cells of this image are 15 to 21 px wide, so a grid of even cells cuts through drawn pixels
77
- somewhere. Xprite puts each cut on a colour edge. The [Benchmark](#benchmark) section has scores
78
- on 1746 cases.
87
+ ### Painterly shading inside cells
88
+
89
+ - [Naga mage, Dungeon Crawl Stone Soup](https://github.com/crawl/tiles), CC0. Category `gen_painterly`. Native art: 31×32.
90
+
91
+ | Input, 411×425 | Xprite, 31×32 ✓ | pixel-art-fixer, 30×33 ✗ | perfectPixel, 31×32 ✓ | proper-pixel-art, 31×34 ✗ |
92
+ | :---: | :---: | :---: | :---: | :---: |
93
+ | ![Input, 411×425](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/painterly-input.png) | ![Xprite](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/painterly-xprite.png) | ![pixel-art-fixer](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/painterly-fixer.png) | ![perfectPixel](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/painterly-perfectpixel.png) | ![proper-pixel-art](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/painterly-proper.png) |
79
94
 
80
95
  ## Install
81
96
 
@@ -208,7 +223,7 @@ Each source file in [`src/`](src) describes its step.
208
223
  benchmark damages the art in known ways and scores each result against the original. Every tool
209
224
  runs with its default settings.
210
225
 
211
- AI suite (1746 cases rendered the way generators fake pixel art):
226
+ AI suite (1746 cases in 12 categories, rendered the way generators fake pixel art):
212
227
 
213
228
  | Method | Exact size | Within 1 cell | Pixel match | ΔE | Half-transparent fringe | Median time |
214
229
  | --- | --- | --- | --- | --- | --- | --- |
@@ -217,6 +232,23 @@ AI suite (1746 cases rendered the way generators fake pixel art):
217
232
  | perfectPixel | 53.3% | 68.0% | 96.7% | 2.42 | - | 0.03 s |
218
233
  | proper-pixel-art | 72.2% | 80.4% | 99.7% | **0.64** | 0.0% | 0.49 s |
219
234
 
235
+ Exact size per category:
236
+
237
+ | Category | Xprite | pixel-art-fixer | perfectPixel | proper-pixel-art |
238
+ | --- | --- | --- | --- | --- |
239
+ | Clean (`gen_clean`) | **93.6%** | 71.7% | 58.4% | 74.6% |
240
+ | Sparse canvas (`gen_sparse`) | **99.0%** | 63.5% | 71.9% | 88.5% |
241
+ | Off-white background (`gen_white`) | 77.7% | 65.2% | 66.1% | **82.1%** |
242
+ | Soft outline (`gen_soft_edge`) | **95.8%** | 61.9% | 67.8% | 82.2% |
243
+ | Drift and WebP (`gen_webp`) | **80.9%** | 40.5% | 57.8% | 71.1% |
244
+ | Halos and JPEG (`gen_halo_jpeg`) | **82.7%** | 52.6% | 60.1% | 72.8% |
245
+ | Painterly shading (`gen_painterly`) | **84.5%** | 39.1% | 67.8% | 79.3% |
246
+ | Small cells (4-8 px) (`gen_small_pitch`) | **72.2%** | 47.9% | 40.2% | 43.8% |
247
+ | Large cells (24-48 px) (`gen_large_pitch`) | 68.2% | 22.0% | 68.2% | **78.0%** |
248
+ | Strong drift (`gen_wobble`) | **73.3%** | 30.8% | 30.8% | 54.1% |
249
+ | Two sprites (`gen_pair`) | **97.1%** | 62.7% | 45.1% | 72.5% |
250
+ | Drop shadow (`gen_shadow`) | **97.3%** | 64.0% | 0.0% | 84.7% |
251
+
220
252
  [pixel-bench](https://github.com/Retro-Diffusion/pixel-bench) suite v1 (7651 cases of upscales and
221
253
  lossy pipelines):
222
254
 
package/README.zh-CN.md CHANGED
@@ -5,20 +5,28 @@
5
5
 
6
6
  [English](https://github.com/rhinoc/xprite-pixelate/blob/main/README.md) | 简体中文
7
7
 
8
- | AI 生成,887×887 | 找到的网格 | 真正的像素画,48×49 |
9
- | :---: | :---: | :---: |
10
- | ![输入](docs/images/griffith-input.png) | ![网格](docs/images/griffith-mesh.png) | ![结果](docs/images/griffith-result.png) |
8
+ 找出 AI 生成像素画中真正的像素网格,每一格还原成一个干净的像素。它也能把普通图片转成像素画。它可以在浏览器和 Node 中运行,没有运行时依赖,是像素编辑器 [Xprite](https://xprite.cc) 的导入器。
11
9
 
12
- ## 简介
10
+ ## 与其他工具对比
11
+
12
+ 一张真实的 AI 生成图(887×887,格宽 15 到 21 像素不等),各工具用默认设置还原的结果。Xprite 把每一刀都切在颜色边缘上,所以不会切开眼睛、靴子和剑。
13
13
 
14
- 图像生成模型画出的“像素画”边缘发虚,有噪点,轮廓半透明,每一格的宽度也不一样。这个包找出图里真正的像素网格,每一格还原成一个干净的像素。它也能把普通图片转成像素画。
14
+ | 找到的网格 | Xprite,48×49 | [pixel-art-fixer](https://github.com/Retro-Diffusion/pixel-art-fixer),47×48 | [perfectPixel](https://github.com/theamusing/perfectPixel),50×50 | [proper-pixel-art](https://github.com/KennethJAllen/proper-pixel-art),53×54 |
15
+ | :---: | :---: | :---: | :---: | :---: |
16
+ | ![网格](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/griffith-mesh.png) | ![Xprite](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/griffith-xprite.png) | ![pixel-art-fixer](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/griffith-fixer.png) | ![perfectPixel](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/griffith-perfectpixel.png) | ![proper-pixel-art](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/griffith-proper.png) |
15
17
 
16
- 它可以在浏览器和 Node 中运行,没有运行时依赖,包内自带一个 WebAssembly 模块。它是像素编辑器 [Xprite](https://xprite.cc) 的导入器。
18
+ 在[我们的基准测试](#基准测试)的 AI 套件(1746 个用例)上,Xprite 得到正确尺寸的次数最多:
19
+
20
+ | 方法 | 尺寸完全正确 | 差 1 格以内 | 像素一致率 | 半透明毛边 | 中位耗时 |
21
+ | --- | --- | --- | --- | --- | --- |
22
+ | Xprite Auto | **83.6%** | **90.0%** | **99.8%** | 0.1% | 1.55 s |
23
+ | pixel-art-fixer | 49.7% | 80.9% | 98.3% | 0.0% | 0.18 s |
24
+ | perfectPixel | 53.3% | 68.0% | 96.7% | - | 0.03 s |
25
+ | proper-pixel-art | 72.2% | 80.4% | 99.7% | 0.0% | 0.49 s |
17
26
 
18
27
  ## 目录
19
28
 
20
29
  - [示例](#示例)
21
- - [与其他工具对比](#与其他工具对比)
22
30
  - [安装](#安装)
23
31
  - [用法](#用法)
24
32
  - [原理](#原理)
@@ -27,49 +35,55 @@
27
35
 
28
36
  ## 示例
29
37
 
30
- 下面的输入来自基准测试的 AI 套件:把 CC0 像素画按生成模型的方式渲染成假像素画。每个结果的尺寸都和原画完全一致。
38
+ 每个示例取自基准测试 AI 套件的一个类别:把 CC0 像素画按生成模型的方式渲染,原画尺寸已知。尺寸是可见画面的格数,✓ 表示与原画尺寸完全一致。每个工具都使用默认设置。
31
39
 
32
40
  ### 一张画布上的两个角色
33
41
 
34
- - 哥布林,作者 LuizMelo([Monsters Creatures Fantasy](https://luizmelo.itch.io/monsters-creatures-fantasy),CC0)
42
+ - [哥布林,作者 LuizMelo](https://luizmelo.itch.io/monsters-creatures-fantasy),CC0。类别 `gen_pair`。原画:78×36。
35
43
 
36
- | 输入,1800×845 | 找到的网格 | 结果,103×49 |
37
- | :---: | :---: | :---: |
38
- | ![输入](docs/images/goblins-input.png) | ![网格](docs/images/goblins-mesh.png) | ![结果](docs/images/goblins-result.png) |
44
+ | 输入,1800×845 | Xprite,78×36 ✓ | pixel-art-fixer,78×35 ✗ | perfectPixel,80×36 ✗ | proper-pixel-art,79×36 ✗ |
45
+ | :---: | :---: | :---: | :---: | :---: |
46
+ | ![输入,1800×845](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/pair-input.png) | ![Xprite](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/pair-xprite.png) | ![pixel-art-fixer](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/pair-fixer.png) | ![perfectPixel](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/pair-perfectpixel.png) | ![proper-pixel-art](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/pair-proper.png) |
39
47
 
40
- ### 格内有绘画式明暗
48
+ ### 格子漂移和抖动
41
49
 
42
- - 娜迦法师,来自 [Dungeon Crawl Stone Soup tiles](https://github.com/crawl/tiles)(CC0)
50
+ - [巨龙,作者 ansimuz](https://opengameart.org/content/sideview-fantasy-patreon-collection),CC0。类别 `gen_wobble`。原画:71×39。
43
51
 
44
- | 输入,411×425 | 找到的网格 | 结果,50×50 |
45
- | :---: | :---: | :---: |
46
- | ![输入](docs/images/naga-input.png) | ![网格](docs/images/naga-mesh.png) | ![结果](docs/images/naga-result.png) |
52
+ | 输入,1226×664 | Xprite,71×39 ✓ | pixel-art-fixer,69×38 ✗ | perfectPixel,74×39 ✗ | proper-pixel-art,69×38 ✗ |
53
+ | :---: | :---: | :---: | :---: | :---: |
54
+ | ![输入,1226×664](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/wobble-input.png) | ![Xprite](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/wobble-xprite.png) | ![pixel-art-fixer](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/wobble-fixer.png) | ![perfectPixel](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/wobble-perfectpixel.png) | ![proper-pixel-art](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/wobble-proper.png) |
47
55
 
48
- ### 格子漂移和抖动
56
+ ### 小格子和 WebP 压缩损伤
49
57
 
50
- - 怪物,作者 Denzi([Denzi's public domain art](https://opengameart.org/content/denzis-public-domain-art),CC0)
58
+ - [怪物,作者 Denzi](https://opengameart.org/content/denzis-public-domain-art),CC0。类别 `gen_small_pitch`。原画:32×48。
51
59
 
52
- | 输入,606×924 | 找到的网格 | 结果,45×67 |
53
- | :---: | :---: | :---: |
54
- | ![输入](docs/images/wobble-input.png) | ![网格](docs/images/wobble-mesh.png) | ![结果](docs/images/wobble-result.png) |
60
+ | 输入,218×339 | Xprite,32×48 ✓ | pixel-art-fixer,32×47 ✗ | perfectPixel,32×49 ✗ | proper-pixel-art,34×49 ✗ |
61
+ | :---: | :---: | :---: | :---: | :---: |
62
+ | ![输入,218×339](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/small-input.png) | ![Xprite](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/small-xprite.png) | ![pixel-art-fixer](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/small-fixer.png) | ![perfectPixel](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/small-perfectpixel.png) | ![proper-pixel-art](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/small-proper.png) |
55
63
 
56
- ### 小格子和 WebP 压缩损伤
64
+ ### 大块透明画布上的小角色
57
65
 
58
- - 老人,作者 ansimuz([Gothicvania Town](https://opengameart.org/content/gothicvania-town),CC0)
66
+ - [猫耳少女,作者 cawfeecrow](https://opengameart.org/content/nekomimi-girl-portrait),CC0。类别 `gen_sparse`。原画:123×136。
59
67
 
60
- | 输入,250×380 | 找到的网格 | 结果,39×57 |
61
- | :---: | :---: | :---: |
62
- | ![输入](docs/images/oldman-input.png) | ![网格](docs/images/oldman-mesh.png) | ![结果](docs/images/oldman-result.png) |
68
+ | 输入,1797×1800 | Xprite,123×136 ✓ | pixel-art-fixer,122×136 ✗ | perfectPixel,124×136 ✗ | proper-pixel-art,127×142 ✗ |
69
+ | :---: | :---: | :---: | :---: | :---: |
70
+ | ![输入,1797×1800](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/sparse-input.png) | ![Xprite](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/sparse-xprite.png) | ![pixel-art-fixer](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/sparse-fixer.png) | ![perfectPixel](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/sparse-perfectpixel.png) | ![proper-pixel-art](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/sparse-proper.png) |
63
71
 
64
- ## 与其他工具对比
72
+ ### 近白色背景
65
73
 
66
- 顶部那张图,各工具用默认设置还原的结果:
74
+ - [飞龙,作者 ansimuz](https://opengameart.org/content/sideview-fantasy-patreon-collection),CC0。类别 `gen_white`。原画:162×106。
67
75
 
68
- | Xprite Auto,48×49 | [pixel-art-fixer](https://github.com/Retro-Diffusion/pixel-art-fixer),47×48 | [perfectPixel](https://github.com/theamusing/perfectPixel),50×50 | [proper-pixel-art](https://github.com/KennethJAllen/proper-pixel-art),53×54 |
69
- | :---: | :---: | :---: | :---: |
70
- | ![Xprite](docs/images/griffith-result.png) | ![pixel-art-fixer](docs/images/griffith-fixer.png) | ![perfectPixel](docs/images/griffith-perfectpixel.png) | ![proper-pixel-art](docs/images/griffith-proper.png) |
76
+ | 输入,1800×1210 | Xprite,162×106 ✓ | pixel-art-fixer,325×208 ✗ | perfectPixel,161×105 ✗ | proper-pixel-art,168×106 ✗ |
77
+ | :---: | :---: | :---: | :---: | :---: |
78
+ | ![输入,1800×1210](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/white-input.png) | ![Xprite](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/white-xprite.png) | ![pixel-art-fixer](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/white-fixer.png) | ![perfectPixel](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/white-perfectpixel.png) | ![proper-pixel-art](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/white-proper.png) |
71
79
 
72
- 这张图的格宽在 15 到 21 像素之间,所以等宽网格总会在某处切进画好的像素。Xprite 把每一刀都切在颜色边缘上。1746 个用例的得分见[基准测试](#基准测试)。
80
+ ### 格内有绘画式明暗
81
+
82
+ - [娜迦法师,Dungeon Crawl Stone Soup](https://github.com/crawl/tiles),CC0。类别 `gen_painterly`。原画:31×32。
83
+
84
+ | 输入,411×425 | Xprite,31×32 ✓ | pixel-art-fixer,30×33 ✗ | perfectPixel,31×32 ✓ | proper-pixel-art,31×34 ✗ |
85
+ | :---: | :---: | :---: | :---: | :---: |
86
+ | ![输入,411×425](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/painterly-input.png) | ![Xprite](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/painterly-xprite.png) | ![pixel-art-fixer](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/painterly-fixer.png) | ![perfectPixel](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/painterly-perfectpixel.png) | ![proper-pixel-art](https://raw.githubusercontent.com/rhinoc/xprite-pixelate/main/docs/images/painterly-proper.png) |
73
87
 
74
88
  ## 安装
75
89
 
@@ -184,7 +198,7 @@ const grid = await detectWithAlgorithmAsync(image);
184
198
 
185
199
  [`bench/`](bench) 在 CC0 原生像素画上比较本包和另外三个工具。基准测试以已知方式损伤原画,再把每个结果和原画对比打分。每个工具都使用默认设置。
186
200
 
187
- AI 套件(1746 个用例,按生成模型伪造像素画的方式渲染):
201
+ AI 套件(12 个类别共 1746 个用例,按生成模型伪造像素画的方式渲染):
188
202
 
189
203
  | 方法 | 尺寸完全正确 | 差 1 格以内 | 像素一致率 | ΔE | 半透明毛边 | 中位耗时 |
190
204
  | --- | --- | --- | --- | --- | --- | --- |
@@ -193,6 +207,23 @@ AI 套件(1746 个用例,按生成模型伪造像素画的方式渲染):
193
207
  | perfectPixel | 53.3% | 68.0% | 96.7% | 2.42 | - | 0.03 s |
194
208
  | proper-pixel-art | 72.2% | 80.4% | 99.7% | **0.64** | 0.0% | 0.49 s |
195
209
 
210
+ 各类别的尺寸完全正确率:
211
+
212
+ | 类别 | Xprite | pixel-art-fixer | perfectPixel | proper-pixel-art |
213
+ | --- | --- | --- | --- | --- |
214
+ | 干净 (`gen_clean`) | **93.6%** | 71.7% | 58.4% | 74.6% |
215
+ | 稀疏画布 (`gen_sparse`) | **99.0%** | 63.5% | 71.9% | 88.5% |
216
+ | 近白色背景 (`gen_white`) | 77.7% | 65.2% | 66.1% | **82.1%** |
217
+ | 柔和轮廓 (`gen_soft_edge`) | **95.8%** | 61.9% | 67.8% | 82.2% |
218
+ | 漂移和 WebP (`gen_webp`) | **80.9%** | 40.5% | 57.8% | 71.1% |
219
+ | 光晕和 JPEG (`gen_halo_jpeg`) | **82.7%** | 52.6% | 60.1% | 72.8% |
220
+ | 绘画式明暗 (`gen_painterly`) | **84.5%** | 39.1% | 67.8% | 79.3% |
221
+ | 小格子(4-8 px) (`gen_small_pitch`) | **72.2%** | 47.9% | 40.2% | 43.8% |
222
+ | 大格子(24-48 px) (`gen_large_pitch`) | 68.2% | 22.0% | 68.2% | **78.0%** |
223
+ | 强漂移 (`gen_wobble`) | **73.3%** | 30.8% | 30.8% | 54.1% |
224
+ | 两个角色 (`gen_pair`) | **97.1%** | 62.7% | 45.1% | 72.5% |
225
+ | 投影 (`gen_shadow`) | **97.3%** | 64.0% | 0.0% | 84.7% |
226
+
196
227
  [pixel-bench](https://github.com/Retro-Diffusion/pixel-bench) v1 套件(7651 个放大和有损处理用例):
197
228
 
198
229
  | 方法 | 尺寸完全正确 | 差 1 格以内 | 像素一致率 | ΔE | 中位耗时 |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xprite/pixelate",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Recover the real pixel grid of AI-generated and upscaled pixel art, and turn images into pixel art.",
5
5
  "license": "MIT",
6
6
  "author": "rhinoc",