gpujs / gpujs/gpu.js

Getting wrong color when drawing large image

Abierto
#707 2 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
15.5k
Forks
663
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

First of all , thank you for your great work.
I've been trying to follow [wobbling cat](https://observablehq.com/@fil/image-to-gpu) example but first I started by redrawing an image. I use nodejs and getPixels() method instead of getting a canvas. It all works fine with cat.jpg and other 1000 x 1000 images but when I use large (3634x5451) image this is what happened.


![rotated](https://user-images.githubusercontent.com/6382447/127479252-b584a6aa-ef0c-4a23-b860-c67f2f95b9f3.jpeg)

**CODE**
```
const kernel = function(image) {
let x = this.thread.x,
y = this.thread.y;

const n = 4 * ( x + this.constants.w * (this.constants.h - y) );
this.color(image[n] / 256, image[n+1] / 256, image[n+2] / 256, image[n+3] / 256)
}

const drawImage = gpu.createKernel(kernel)
.setConstants({ w: width, h: height})
.setOutput([width, height])
.setGraphical(true)

drawImage(buffer)
const pixels = drawImage.getPixels()
gpu.destroy()

// write image file with returned pixels
```

**Running on**

- NodeJS : 14.17.3
- gpu.js : 2.11.3
- jpeg-js : 0.4.3
- AMD Radeon Pro 5300M

**Original image**
It should just redraw the same image.

![car](https://user-images.githubusercontent.com/6382447/127481060-3d502e8a-052a-4c69-ae70-3986c492c133.jpeg)

Importance : 3

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Empieza reproduciendo el kernel drawImage reportado usando nodejs, getPixels() y la imagen de 3634x5451, comparándolo con el caso exitoso de 1000x1000. Inspecciona la salida de setGraphical(true) y la ruta de lectura de píxeles; se considera terminado cuando la imagen grande se redibuja con colores coincidentes en lugar de la salida incorrecta reportada.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, nodejs
Área
computer-graphics
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.