Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
No se pueden leer las propiedades de undefined (leyendo 'ancho') - procesamiento de imágenes p5.js

Mi código está destinado a mostrar la misma imagen una al lado de la otra, donde la imagen de la izquierda es la original y la imagen de la derecha tiene un filtro. Puedo ver que el filtro funciona, pero la imagen alterada se muestra repetidamente a lo ancho del lienzo en la parte superior.

También recibo el error "Cannot read properties of undefined (reading 'width')" for line 'image(Filter(img), img.width, 0);' .

Supongo que hay un problema con la función de filtro y el parámetro no se llama correctamente, pero no estoy seguro.

 var img; function preload() { img = loadImage("https://www.paulwheeler.us/files/no_idea_why.jpg"); } function setup() { createCanvas((img.width * 2), img.height); } function draw() { background(125); image(imgIn, 0, 0); image(Filter(img), img.width, 0); noLoop(); } function mousePressed() { loop(); } function Filter(update) { var resultImg = createImage(img.width, img.height); resultImg = sepiaFilter(update); return resultImg; } function sepiaFilter(input) { loadPixels(); input.loadPixels(); for (var x = 0; x < input.width; x++) { for (var y = 0; y < input.height; y++) { var index = (y * input.width + x) * 4; var r = input.pixels[index + 0]; var g = input.pixels[index + 1]; var b = input.pixels[index + 2]; var newRed = (r * 0.4) + (g * 0.8) + (b * 0.2) var newGreen = (r * 0.3) + (g * 0.7) + (b * 0.2) var newBlue = (r * 0.3) + (g * 0.5) + (b * 0.1) pixels[index + 0] = newRed; pixels[index + 1] = newGreen; pixels[index + 2] = newBlue; pixels[index + 3] = 255; } } updatePixels(); }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.1/p5.js"></script>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

El problema es que la función sepiaFilter no devuelve un valor. Como resultado, cuando llama a image(earlyBirdFilter(imgIn), imgIn.width, 0); está llamando efectivamente a la image(undefined, imgIn.width, 0); lo que da como resultado el error.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!