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 4018586
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:00:04+00:00 2026-05-20T10:00:04+00:00

I have an 8bit Image (stored in an Array) containing black(0) and white(255) pixels.

  • 0

I have an 8bit Image (stored in an Array) containing black(0) and white(255) pixels. Say I want to change all Black pixels in the image to grey(say 120) pixels. What is the fastest way I can change Black to Grey.

I thought of two approaches-

  1. Start checking every single pixel in the image. As soon as a black pixel is found change it to grey. Continue till end of image. (Slower but easier)

  2. Start checking pixels. When a black pixel is found maintain a counter to track it. Continue incrementing the counter till the next white pixel. Then goto the counter and use a fast function like memset to change a group of black pixels to grey. (Not sure but I think this may be faster)

I have a huge 1GB image therefore approach 1 is pretty slow. Is there a better(faster) way to change/edit pixels?

  • 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-20T10:00:05+00:00Added an answer on May 20, 2026 at 10:00 am

    Probably quicker to do it a word at a time (using word aligned accesses).

    You can just bitwise OR with 0x78787878 (assuming 32 bits). This will not affect white pixels but will set black pixels to the required value.

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

Sidebar

Related Questions

I have a black-white tiff image with 15369x15360 pixels and 8 bit depth now
Say we have an 8-bit unsigned integer n ( UINT8_MAX=255 ); what is the
Supposing I have 4 bitmaps, say, CMYK, all of which are 1bit/pixel and are
I want to subtract two signed 8bit integers in JavaScript. As JavaScript doesn't have
I have an 8bit tiff thats 14406x9606 pixels that when loaded via BitmapImage throws
I have tif image in 16 bit format. Now I want to convert this
If I have a int32 type integer in the 8-bit processor's memory, say, 8051,
I want to convert the input 24 bit PNG image to 8 bit, I
I have a form that, among other things, accepts an image for upload and
I have an image which captures 8 bit. I'm looking to convert the 8

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.