Skip to content

Commit dcd33cf

Browse files
Replace a fixed chunk value with the hardware concurrency value.
1 parent aa50275 commit dcd33cf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/utils/image.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -687,10 +687,9 @@ export class RawImage {
687687
* Performs a Gaussian blur on the image.
688688
* @param {number} kernelSize - Kernel size (must be odd).
689689
* @param {number} sigma - Standard deviation of the Gaussian.
690-
* @param {number} numChunks - Number of chunks to divide the image into for parallel processing.
691690
* @returns {Promise<RawImage>} - The blurred image.
692691
*/
693-
async gaussianBlur(kernelSize = 3, sigma = 1, numChunks = 4) {
692+
async gaussianBlur(kernelSize = 3, sigma = 1) {
694693
const kernel = this.generateGaussianKernel(kernelSize, sigma);
695694
const halfSize = Math.floor(kernelSize / 2);
696695

@@ -705,6 +704,7 @@ export class RawImage {
705704
const horizontalPass = new Float32Array(this.data.length);
706705
const verticalPass = new Uint8ClampedArray(this.data.length);
707706

707+
const numChunks = navigator.hardwareConcurrency || 4;
708708
const chunkHeight = Math.ceil(height / numChunks);
709709

710710
// Process horizontal pass in chunks.

0 commit comments

Comments
 (0)