picross-image-processor 1.0.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,144 @@
1
+ # Picross Image Processor
2
+
3
+ A TypeScript library to convert images to picross (nonogram) board representations by detecting contours and color changes.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install picross-image-processor
9
+ ```
10
+
11
+ ### Optional Canvas Support (Node.js only)
12
+
13
+ For Node.js file processing, optionally install canvas:
14
+
15
+ ```bash
16
+ npm install canvas
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ### Browser - From URL
22
+
23
+ ```typescript
24
+ import { processImageUrl } from 'picross-image-processor';
25
+
26
+ async function createPicrossBoard() {
27
+ const result = await processImageUrl('https://example.com/pokemon.png');
28
+ console.log(result.board); // 16x16 board
29
+ console.log(result.boardSize); // 16
30
+ }
31
+ ```
32
+
33
+ ### Browser - From Canvas
34
+
35
+ ```typescript
36
+ import { processImageData } from 'picross-image-processor';
37
+
38
+ const canvas = document.getElementById('myCanvas') as HTMLCanvasElement;
39
+ const ctx = canvas.getContext('2d');
40
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
41
+
42
+ const result = processImageData(imageData);
43
+ ```
44
+
45
+ ### Node.js - From File
46
+
47
+ ```typescript
48
+ import { processImageFile } from 'picross-image-processor';
49
+
50
+ async function processLocalImage() {
51
+ const result = await processImageFile('./pokemon.png');
52
+ console.log(result.board);
53
+ }
54
+ ```
55
+
56
+ ### With Custom Configuration
57
+
58
+ ```typescript
59
+ import { processImageUrl, ProcessingConfig } from 'picross-image-processor';
60
+
61
+ const config: ProcessingConfig = {
62
+ boardSize: 32, // Default: 16
63
+ colorThreshold: 100, // Default: 80 (0-255)
64
+ alphaThreshold: 128 // Default: 128 (0-255)
65
+ };
66
+
67
+ const result = await processImageUrl(imageUrl, config);
68
+ ```
69
+
70
+ ## Configuration
71
+
72
+ ### `ProcessingConfig`
73
+
74
+ - **boardSize** (number, default: 16): The size of the output picross board (NxN)
75
+ - **colorThreshold** (number, default: 80): The minimum color difference to detect edges (0-255, lower = more sensitive)
76
+ - **alphaThreshold** (number, default: 128): The minimum alpha value to consider a pixel opaque (0-255)
77
+
78
+ ## How It Works
79
+
80
+ 1. **Bounding Box Detection**: Finds the smallest rectangle containing all opaque pixels
81
+ 2. **Crop and Scale**: Crops the image to the bounding box and scales it to the board size
82
+ 3. **Contour Detection**: Marks pixels adjacent to transparent areas
83
+ 4. **Color Change Detection**: Marks pixels with significant color differences to neighbors
84
+ 5. **Binary Board**: Creates a 2D array where 1 = filled cell, 0 = empty cell
85
+
86
+ ## API Reference
87
+
88
+ ### `processImageData(imageData: ImageData, config?: ProcessingConfig): ProcessingResult`
89
+
90
+ Process ImageData directly (browser compatible).
91
+
92
+ ### `processImageUrl(imageUrl: string, config?: ProcessingConfig): Promise<ProcessingResult>`
93
+
94
+ Process an image from a URL (browser compatible, requires CORS).
95
+
96
+ ### `processCanvasImage(image: HTMLImageElement | HTMLCanvasElement, config?: ProcessingConfig): Promise<ProcessingResult>`
97
+
98
+ Process an HTML image element or canvas.
99
+
100
+ ### `processImageFile(filePath: string, config?: ProcessingConfig): Promise<ProcessingResult>`
101
+
102
+ Process an image from a file path (Node.js only, requires canvas package).
103
+
104
+ ## Result
105
+
106
+ The `ProcessingResult` contains:
107
+
108
+ ```typescript
109
+ {
110
+ board: number[][]; // 2D array of 0s and 1s
111
+ boardSize: number; // Size of the board
112
+ }
113
+ ```
114
+
115
+ ## Example: Drawing the Board
116
+
117
+ ```typescript
118
+ function drawBoard(result: ProcessingResult) {
119
+ const { board, boardSize } = result;
120
+ const canvas = document.getElementById('board') as HTMLCanvasElement;
121
+ const ctx = canvas.getContext('2d');
122
+
123
+ const cellSize = 20;
124
+ canvas.width = boardSize * cellSize;
125
+ canvas.height = boardSize * cellSize;
126
+
127
+ for (let row = 0; row < boardSize; row++) {
128
+ for (let col = 0; col < boardSize; col++) {
129
+ const x = col * cellSize;
130
+ const y = row * cellSize;
131
+
132
+ ctx.fillStyle = board[row][col] === 1 ? '#333' : '#fff';
133
+ ctx.fillRect(x, y, cellSize, cellSize);
134
+ ctx.strokeStyle = '#ccc';
135
+ ctx.strokeRect(x, y, cellSize, cellSize);
136
+ }
137
+ }
138
+ }
139
+ ```
140
+
141
+ ## License
142
+
143
+ MIT
144
+
@@ -0,0 +1,19 @@
1
+ import { ProcessingConfig, ProcessingResult } from './types';
2
+ /**
3
+ * Process ImageData directly
4
+ */
5
+ export declare function processImageData(imageData: ImageData, config?: ProcessingConfig): ProcessingResult;
6
+ /**
7
+ * Process an image using Canvas API (browser compatible)
8
+ */
9
+ export declare function processCanvasImage(image: HTMLImageElement | HTMLCanvasElement, config?: ProcessingConfig): Promise<ProcessingResult>;
10
+ /**
11
+ * Process an image from a data URL (browser compatible)
12
+ */
13
+ export declare function processImageUrl(imageUrl: string, config?: ProcessingConfig): Promise<ProcessingResult>;
14
+ /**
15
+ * Process using canvas library (Node.js)
16
+ * This will use the canvas package if available
17
+ */
18
+ export declare function processImageFile(filePath: string, config?: ProcessingConfig): Promise<ProcessingResult>;
19
+ //# sourceMappingURL=imageProcessor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imageProcessor.d.ts","sourceRoot":"","sources":["../src/imageProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAQ7D;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,SAAS,EACpB,MAAM,CAAC,EAAE,gBAAgB,GACxB,gBAAgB,CAiDlB;AA0CD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,gBAAgB,GAAG,iBAAiB,EAC3C,MAAM,CAAC,EAAE,gBAAgB,GACxB,OAAO,CAAC,gBAAgB,CAAC,CAS3B;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,gBAAgB,GACxB,OAAO,CAAC,gBAAgB,CAAC,CAkB3B;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,gBAAgB,GACxB,OAAO,CAAC,gBAAgB,CAAC,CAiB3B"}
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.processImageData = processImageData;
4
+ exports.processCanvasImage = processCanvasImage;
5
+ exports.processImageUrl = processImageUrl;
6
+ exports.processImageFile = processImageFile;
7
+ const pixelAnalysis_1 = require("./utils/pixelAnalysis");
8
+ const imageAnalysis_1 = require("./utils/imageAnalysis");
9
+ /**
10
+ * Process ImageData directly
11
+ */
12
+ function processImageData(imageData, config) {
13
+ const boardSize = config?.boardSize || 16;
14
+ const colorThreshold = config?.colorThreshold || 80;
15
+ const alphaThreshold = config?.alphaThreshold || 128;
16
+ const data = imageData.data;
17
+ const width = imageData.width;
18
+ const height = imageData.height;
19
+ // Step 1: Find bounding box
20
+ const bbox = (0, imageAnalysis_1.calculateBoundingBox)(data, width, height, alphaThreshold);
21
+ // Step 2: Create scaled image data
22
+ const scaledData = scaleImageData(data, width, height, bbox, boardSize);
23
+ // Step 3: Convert to binary matrix
24
+ const board = Array.from({ length: boardSize }, () => Array(boardSize).fill(0));
25
+ for (let row = 0; row < boardSize; row++) {
26
+ for (let col = 0; col < boardSize; col++) {
27
+ const isOpaquePixel = (0, pixelAnalysis_1.isOpaque)(scaledData, boardSize, row, col, alphaThreshold);
28
+ const hasTransparent = (0, pixelAnalysis_1.hasTransparentNeighbor)(scaledData, boardSize, row, col, alphaThreshold);
29
+ const hasColorChange = (0, pixelAnalysis_1.hasSignificantColorChange)(scaledData, boardSize, row, col, colorThreshold, alphaThreshold);
30
+ if (isOpaquePixel && (hasTransparent || hasColorChange)) {
31
+ board[row][col] = 1;
32
+ }
33
+ }
34
+ }
35
+ return {
36
+ board,
37
+ boardSize,
38
+ };
39
+ }
40
+ /**
41
+ * Scale image data from source bbox to target board size
42
+ */
43
+ function scaleImageData(sourceData, sourceWidth, sourceHeight, bbox, boardSize) {
44
+ const scaledData = new Uint8ClampedArray(boardSize * boardSize * 4);
45
+ const { minX, minY, width: bboxWidth, height: bboxHeight } = bbox;
46
+ for (let targetRow = 0; targetRow < boardSize; targetRow++) {
47
+ for (let targetCol = 0; targetCol < boardSize; targetCol++) {
48
+ // Map target pixel to source pixel
49
+ const sourceCol = Math.floor((targetCol / boardSize) * bboxWidth) + minX;
50
+ const sourceRow = Math.floor((targetRow / boardSize) * bboxHeight) + minY;
51
+ const sourceIndex = (sourceRow * sourceWidth + sourceCol) * 4;
52
+ const targetIndex = (targetRow * boardSize + targetCol) * 4;
53
+ if (sourceCol >= 0 && sourceCol < sourceWidth && sourceRow >= 0 && sourceRow < sourceHeight) {
54
+ scaledData[targetIndex] = sourceData[sourceIndex];
55
+ scaledData[targetIndex + 1] = sourceData[sourceIndex + 1];
56
+ scaledData[targetIndex + 2] = sourceData[sourceIndex + 2];
57
+ scaledData[targetIndex + 3] = sourceData[sourceIndex + 3];
58
+ }
59
+ else {
60
+ scaledData[targetIndex] = 0;
61
+ scaledData[targetIndex + 1] = 0;
62
+ scaledData[targetIndex + 2] = 0;
63
+ scaledData[targetIndex + 3] = 0;
64
+ }
65
+ }
66
+ }
67
+ return scaledData;
68
+ }
69
+ /**
70
+ * Process an image using Canvas API (browser compatible)
71
+ */
72
+ async function processCanvasImage(image, config) {
73
+ const canvas = new OffscreenCanvas(image.width, image.height);
74
+ const ctx = canvas.getContext('2d');
75
+ if (!ctx)
76
+ throw new Error('Could not get canvas context');
77
+ ctx.drawImage(image, 0, 0);
78
+ const imageData = ctx.getImageData(0, 0, image.width, image.height);
79
+ return processImageData(imageData, config);
80
+ }
81
+ /**
82
+ * Process an image from a data URL (browser compatible)
83
+ */
84
+ async function processImageUrl(imageUrl, config) {
85
+ return new Promise((resolve, reject) => {
86
+ const img = new Image();
87
+ img.crossOrigin = 'Anonymous';
88
+ img.onload = async () => {
89
+ try {
90
+ const result = await processCanvasImage(img, config);
91
+ resolve(result);
92
+ }
93
+ catch (error) {
94
+ reject(error);
95
+ }
96
+ };
97
+ img.onerror = () => reject(new Error('Failed to load image'));
98
+ img.src = imageUrl;
99
+ });
100
+ }
101
+ /**
102
+ * Process using canvas library (Node.js)
103
+ * This will use the canvas package if available
104
+ */
105
+ async function processImageFile(filePath, config) {
106
+ try {
107
+ // Try to use canvas library if available
108
+ const canvas = require('canvas');
109
+ const image = await canvas.loadImage(filePath);
110
+ const processCanvas = canvas.createCanvas(image.width, image.height);
111
+ const ctx = processCanvas.getContext('2d');
112
+ ctx.drawImage(image, 0, 0);
113
+ const imageData = ctx.getImageData(0, 0, image.width, image.height);
114
+ return processImageData(imageData, config);
115
+ }
116
+ catch (error) {
117
+ throw new Error('Canvas library not available. Install canvas package for Node.js support: npm install canvas');
118
+ }
119
+ }
120
+ //# sourceMappingURL=imageProcessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imageProcessor.js","sourceRoot":"","sources":["../src/imageProcessor.ts"],"names":[],"mappings":";;AAWA,4CAoDC;AA6CD,gDAYC;AAKD,0CAqBC;AAMD,4CAoBC;AA3KD,yDAI+B;AAC/B,yDAA6D;AAE7D;;GAEG;AACH,SAAgB,gBAAgB,CAC9B,SAAoB,EACpB,MAAyB;IAEzB,MAAM,SAAS,GAAG,MAAM,EAAE,SAAS,IAAI,EAAE,CAAC;IAC1C,MAAM,cAAc,GAAG,MAAM,EAAE,cAAc,IAAI,EAAE,CAAC;IACpD,MAAM,cAAc,GAAG,MAAM,EAAE,cAAc,IAAI,GAAG,CAAC;IAErD,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC;IAC5B,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC;IAC9B,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;IAEhC,4BAA4B;IAC5B,MAAM,IAAI,GAAG,IAAA,oCAAoB,EAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;IAEvE,mCAAmC;IACnC,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IAExE,mCAAmC;IACnC,MAAM,KAAK,GAAe,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,CAC/D,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACzB,CAAC;IAEF,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,SAAS,EAAE,GAAG,EAAE,EAAE,CAAC;QACzC,KAAK,IAAI,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,CAAC,QAAQ,CAAC,CAAC;QACjC,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAE/C,MAAM,aAAa,GAAG,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QACrE,MAAM,GAAG,GAAG,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC3C,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAE3B,MAAM,SAAS,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QACpE,OAAO,gBAAgB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAC7C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,8FAA8F,CAC/F,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './types';
2
+ export { processImageData, processCanvasImage, processImageUrl, processImageFile, } from './imageProcessor';
3
+ export * from './utils/pixelAnalysis';
4
+ export * from './utils/imageAnalysis';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,CAAC;AACxB,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.processImageFile = exports.processImageUrl = exports.processCanvasImage = exports.processImageData = void 0;
18
+ // Main entry point
19
+ __exportStar(require("./types"), exports);
20
+ var imageProcessor_1 = require("./imageProcessor");
21
+ Object.defineProperty(exports, "processImageData", { enumerable: true, get: function () { return imageProcessor_1.processImageData; } });
22
+ Object.defineProperty(exports, "processCanvasImage", { enumerable: true, get: function () { return imageProcessor_1.processCanvasImage; } });
23
+ Object.defineProperty(exports, "processImageUrl", { enumerable: true, get: function () { return imageProcessor_1.processImageUrl; } });
24
+ Object.defineProperty(exports, "processImageFile", { enumerable: true, get: function () { return imageProcessor_1.processImageFile; } });
25
+ __exportStar(require("./utils/pixelAnalysis"), exports);
26
+ __exportStar(require("./utils/imageAnalysis"), exports);
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mBAAmB;AACnB,0CAAwB;AACxB,mDAK0B;AAJxB,kHAAA,gBAAgB,OAAA;AAChB,oHAAA,kBAAkB,OAAA;AAClB,iHAAA,eAAe,OAAA;AACf,kHAAA,gBAAgB,OAAA;AAElB,wDAAsC;AACtC,wDAAsC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Represents pixel data with RGBA values
3
+ */
4
+ export interface PixelData {
5
+ r: number;
6
+ g: number;
7
+ b: number;
8
+ a: number;
9
+ }
10
+ /**
11
+ * Configuration options for image processing
12
+ */
13
+ export interface ProcessingConfig {
14
+ boardSize?: number;
15
+ colorThreshold?: number;
16
+ alphaThreshold?: number;
17
+ }
18
+ /**
19
+ * Result of image processing containing the picross board
20
+ */
21
+ export interface ProcessingResult {
22
+ board: number[][];
23
+ boardSize: number;
24
+ }
25
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB"}
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Find the bounding box of all opaque pixels in the image
3
+ */
4
+ export interface BoundingBox {
5
+ minX: number;
6
+ minY: number;
7
+ maxX: number;
8
+ maxY: number;
9
+ width: number;
10
+ height: number;
11
+ }
12
+ /**
13
+ * Calculate bounding box of opaque pixels in image data
14
+ */
15
+ export declare function calculateBoundingBox(data: Uint8ClampedArray | Uint8Array, width: number, height: number, alphaThreshold?: number): BoundingBox;
16
+ //# sourceMappingURL=imageAnalysis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imageAnalysis.d.ts","sourceRoot":"","sources":["../../src/utils/imageAnalysis.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,iBAAiB,GAAG,UAAU,EACpC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,cAAc,GAAE,MAAY,GAC3B,WAAW,CAwBb"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateBoundingBox = calculateBoundingBox;
4
+ /**
5
+ * Calculate bounding box of opaque pixels in image data
6
+ */
7
+ function calculateBoundingBox(data, width, height, alphaThreshold = 128) {
8
+ let minX = width;
9
+ let minY = height;
10
+ let maxX = 0;
11
+ let maxY = 0;
12
+ for (let y = 0; y < height; y++) {
13
+ for (let x = 0; x < width; x++) {
14
+ const index = (y * width + x) * 4;
15
+ const alpha = data[index + 3];
16
+ if (alpha > alphaThreshold) {
17
+ minX = Math.min(minX, x);
18
+ minY = Math.min(minY, y);
19
+ maxX = Math.max(maxX, x);
20
+ maxY = Math.max(maxY, y);
21
+ }
22
+ }
23
+ }
24
+ const cropWidth = maxX - minX + 1;
25
+ const cropHeight = maxY - minY + 1;
26
+ return { minX, minY, maxX, maxY, width: cropWidth, height: cropHeight };
27
+ }
28
+ //# sourceMappingURL=imageAnalysis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imageAnalysis.js","sourceRoot":"","sources":["../../src/utils/imageAnalysis.ts"],"names":[],"mappings":";;AAeA,oDA6BC;AAhC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
+ /**
3
+ * Get pixel data from ImageData at a specific row and column
4
+ */
5
+ export declare function getPixelData(data: Uint8ClampedArray, boardSize: number, row: number, col: number): PixelData;
6
+ /**
7
+ * Check if a pixel is opaque based on alpha threshold
8
+ */
9
+ export declare function isOpaque(data: Uint8ClampedArray, boardSize: number, row: number, col: number, alphaThreshold?: number): boolean;
10
+ /**
11
+ * Calculate color difference between two pixels using Euclidean distance
12
+ */
13
+ export declare function colorDifference(pixel1: PixelData, pixel2: PixelData): number;
14
+ /**
15
+ * Check if pixel has at least one transparent neighbor
16
+ */
17
+ export declare function hasTransparentNeighbor(data: Uint8ClampedArray, boardSize: number, row: number, col: number, alphaThreshold?: number): boolean;
18
+ /**
19
+ * Check if pixel has significant color change with neighbors
20
+ */
21
+ export declare function hasSignificantColorChange(data: Uint8ClampedArray, boardSize: number, row: number, col: number, colorThreshold?: number, alphaThreshold?: number): boolean;
22
+ //# sourceMappingURL=pixelAnalysis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pixelAnalysis.d.ts","sourceRoot":"","sources":["../../src/utils/pixelAnalysis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC;;GAEG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,iBAAiB,EACvB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,GACV,SAAS,CAYX;AAED;;GAEG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,iBAAiB,EACvB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,cAAc,GAAE,MAAY,GAC3B,OAAO,CAGT;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM,CAW5E;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,iBAAiB,EACvB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,cAAc,GAAE,MAAY,GAC3B,OAAO,CAmBT;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,iBAAiB,EACvB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,cAAc,GAAE,MAAW,EAC3B,cAAc,GAAE,MAAY,GAC3B,OAAO,CA2BT"}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPixelData = getPixelData;
4
+ exports.isOpaque = isOpaque;
5
+ exports.colorDifference = colorDifference;
6
+ exports.hasTransparentNeighbor = hasTransparentNeighbor;
7
+ exports.hasSignificantColorChange = hasSignificantColorChange;
8
+ /**
9
+ * Get pixel data from ImageData at a specific row and column
10
+ */
11
+ function getPixelData(data, boardSize, row, col) {
12
+ if (row < 0 || row >= boardSize || col < 0 || col >= boardSize) {
13
+ return { r: 0, g: 0, b: 0, a: 0 };
14
+ }
15
+ const index = (row * boardSize + col) * 4;
16
+ return {
17
+ r: data[index],
18
+ g: data[index + 1],
19
+ b: data[index + 2],
20
+ a: data[index + 3],
21
+ };
22
+ }
23
+ /**
24
+ * Check if a pixel is opaque based on alpha threshold
25
+ */
26
+ function isOpaque(data, boardSize, row, col, alphaThreshold = 128) {
27
+ const pixel = getPixelData(data, boardSize, row, col);
28
+ return pixel.a > alphaThreshold;
29
+ }
30
+ /**
31
+ * Calculate color difference between two pixels using Euclidean distance
32
+ */
33
+ function colorDifference(pixel1, pixel2) {
34
+ // If either pixel is transparent, return 0
35
+ if (pixel1.a <= 128 || pixel2.a <= 128) {
36
+ return 0;
37
+ }
38
+ const dr = pixel1.r - pixel2.r;
39
+ const dg = pixel1.g - pixel2.g;
40
+ const db = pixel1.b - pixel2.b;
41
+ return Math.sqrt(dr * dr + dg * dg + db * db);
42
+ }
43
+ /**
44
+ * Check if pixel has at least one transparent neighbor
45
+ */
46
+ function hasTransparentNeighbor(data, boardSize, row, col, alphaThreshold = 128) {
47
+ const neighbors = [
48
+ [row - 1, col],
49
+ [row + 1, col],
50
+ [row, col - 1],
51
+ [row, col + 1],
52
+ ];
53
+ for (const [r, c] of neighbors) {
54
+ if (r < 0 || r >= boardSize || c < 0 || c >= boardSize) {
55
+ // Edge of image counts as transparent neighbor
56
+ return true;
57
+ }
58
+ if (!isOpaque(data, boardSize, r, c, alphaThreshold)) {
59
+ return true;
60
+ }
61
+ }
62
+ return false;
63
+ }
64
+ /**
65
+ * Check if pixel has significant color change with neighbors
66
+ */
67
+ function hasSignificantColorChange(data, boardSize, row, col, colorThreshold = 80, alphaThreshold = 128) {
68
+ if (!isOpaque(data, boardSize, row, col, alphaThreshold)) {
69
+ return false;
70
+ }
71
+ const currentPixel = getPixelData(data, boardSize, row, col);
72
+ const neighbors = [
73
+ [row - 1, col],
74
+ [row + 1, col],
75
+ [row, col - 1],
76
+ [row, col + 1],
77
+ ];
78
+ for (const [r, c] of neighbors) {
79
+ if (r >= 0 && r < boardSize && c >= 0 && c < boardSize) {
80
+ const neighborPixel = getPixelData(data, boardSize, r, c);
81
+ if (neighborPixel.a > alphaThreshold) {
82
+ const diff = colorDifference(currentPixel, neighborPixel);
83
+ if (diff > colorThreshold) {
84
+ return true;
85
+ }
86
+ }
87
+ }
88
+ }
89
+ return false;
90
+ }
91
+ //# sourceMappingURL=pixelAnalysis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pixelAnalysis.js","sourceRoot":"","sources":["../../src/utils/pixelAnalysis.ts"],"names":[],"mappings":";;AAKA,oCAiBC;AAKD,4BASC;AAKD,0CAWC;AAKD,wDAyBC;AAKD,8DAkCC;AAvHD;;GAEG;AACH,SAAgB,YAAY,CAC1B,IAAuB,EACvB,SAAiB,EACjB,GAAW,EACX,GAAW;IAEX,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,IAAI,SAAS,IAAI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GAAG,CAAC;QACd,CAAC,GAAG,GAAG,CAAC,EAAE,GAAG,CAAC;QACd,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC;QACd,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC;KACf,CAAC;IAEF,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC;QAC/B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,SAAS,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,SAAS,EAAE,CAAC;YACvD,MAAM,aAAa,GAAG,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC1D,IAAI,aAAa,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;gBACrC,MAAM,IAAI,GAAG,eAAe,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;gBAC1D,IAAI,IAAI,GAAG,cAAc,EAAE,CAAC;oBAC1B,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "picross-image-processor",
3
+ "version": "1.0.0",
4
+ "description": "A library to convert images to picross board representations by detecting contours and color changes",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "README.md",
10
+ "LICENSE"
11
+ ],
12
+ "scripts": {
13
+ "build": "tsc",
14
+ "test": "jest",
15
+ "prepublishOnly": "npm run build"
16
+ },
17
+ "keywords": [
18
+ "picross",
19
+ "nonogram",
20
+ "image-processing",
21
+ "canvas",
22
+ "puzzle",
23
+ "image-to-puzzle"
24
+ ],
25
+ "author": "",
26
+ "license": "MIT",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://github.com/yourusername/picross-image-processor.git"
30
+ },
31
+ "bugs": {
32
+ "url": "https://github.com/yourusername/picross-image-processor/issues"
33
+ },
34
+ "homepage": "https://github.com/yourusername/picross-image-processor#readme",
35
+ "engines": {
36
+ "node": ">=16.0.0"
37
+ },
38
+ "devDependencies": {
39
+ "@types/jest": "^29.5.0",
40
+ "@types/node": "^20.0.0",
41
+ "jest": "^29.5.0",
42
+ "ts-jest": "^29.1.0",
43
+ "typescript": "^5.0.0"
44
+ },
45
+ "peerDependencies": {
46
+ "canvas": "^2.11.2"
47
+ },
48
+ "peerDependenciesMeta": {
49
+ "canvas": {
50
+ "optional": true
51
+ }
52
+ }
53
+ }
54
+