Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7556043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:46:21+00:00 2026-05-30T11:46:21+00:00

Is it possible to read pixels of an image in canvas A and create

  • 0

Is it possible to read pixels of an image in canvas A and create pixels on canvas B? And I want to create the new pixels on Canvas B only where the image’s pixels are green.
eg. If images’ pixel (120,45) is green I need to create a green colored pixel in Canvas B at (120,45)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T11:46:22+00:00Added an answer on May 30, 2026 at 11:46 am

    You can use canvas ImageData to get color values for each pixels. The function:

    context.getImageData(left, top, width, height);
    

    returns an ImageData object, which consists of the following properties:

    • width
    • height
    • data (CanvasPixelArray)

    The CanvasPixelArray contains the RGBA values for all the pixels, starting from top-left working its way to bottom-right. So in other words, it is an array containing 4*width*height number of entries.

    Using that, you can start looping through each pixel (+=4 entries per pixel), and check the RGBA values. If they match a specific value you want, i.e. green, then you would copy that value to a canvas B, which you would create by modifying a newly created ImageData object.

    You can create a new empty ImageData object with:

    context.createImageData(cssWidth, cssHeight)
    

    Note that you will need to know specific RGBA values that identify “green” or define specific conditions, i.e. if the G value of RGBA is >= 150 then it is “green”.

    Also note that you cannot get the ImageData that has been tainted resources outside of your origin. i.e., if you draw an image onto the canvas that isn’t CORS safe, you won’t be able to retrieve the ImageData from that canvas anymore, much like how you can’t use toDataURL either.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to read alphanumeric characters only from the given input line ignoring
I read it should be possible to transfer pixel data directly inside the GPU
Possible Duplicate: read/write to Windows Registry using Java I want to read the registry
Assume you want to read an image file in a common file format from
Is it possible, using only Javascript (no Flash/ActiveX), to read the color of a
I need to display updated images as fast as possible in a Matlab figure.
I know that it is possible read and write data from mongodb via hadoop.
Possible Duplicate: Read Post Data submitted to ASP.Net Form I have a google checkout
Is possible to read from a txt file in loop like this? files names:
Is it possible to read intermittently-sent data through a named pipe using redirection to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.