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

83
Views
Hey im currently trying to make a box blur that only blurs a certain color

with the code blow i am able to blur an image but i have not figured how to blur only a certain color

on the inverse colors comment i was able to only inverse a certain color i basically want to do the same but with bluring instead of inversing the color

    var c = document.getElementById("myCanvas");
    var ctx = c.getContext("2d");
    var img = document.getElementById("scream");
    ctx.drawImage(img, 0, 0);    
    var imgData = ctx.getImageData(0, 0, c.width, c.height);

    // invert colors
    // var i;
    // for (i = 0; i < imgData.data.length; i += 4) {
    //     if (imgData.data[i] == 243 
    //     && imgData.data[i+1] == 83 
    //     && imgData.data[i+2] == 37 
    //     && imgData.data[i+3] == 255){
    //         imgData.data[i] = 255 - imgData.data[i];
    //         imgData.data[i+1] = 255 - imgData.data[i+1];
    //         imgData.data[i+2] = 255 - imgData.data[i+2];
    //         imgData.data[i+3] = 255;            
    //     }

    // }

    var px = imgData.data;
    var tmPx = new Uint8ClampedArray(px.length);

    for (var i=0, len = px.length;i<len;i++){
        tmPx[i] = px[i];

        if (i%4==3){ continue;}

        px[i] = (tmPx[i] 
            + (tmPx[i - 4] || tmPx[i])
            + (tmPx[i + 4] || tmPx[i])
            + (tmPx[i - 4 * imgData.width] || tmPx[i])
            + (tmPx[i + 4 * imgData.width] || tmPx[i])
            + (tmPx[i - 4 * imgData.width -4] || tmPx[i])
            + (tmPx[i + 4 * imgData.width +4] || tmPx[i])
            + (tmPx[i - 4 * imgData.width +4] || tmPx[i])
            + (tmPx[i + 4 * imgData.width -4] || tmPx[i])            
            ) / 9;
    }


    delete tmPx;
    ctx.putImageData(imgData, 0, 0);
    img.remove()
about 4 years ago · Santiago Gelvez
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!