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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:41:56+00:00 2026-06-03T04:41:56+00:00

I am looking to replace pixels in an image that are black to some

  • 0

I am looking to replace pixels in an image that are black to some degree (semi-black) to become fully black.

The method to do this is setRGB(int x, int y, int rgb). I know this. What I do not know is how to detect pixels that are semi-black.

I have tried (i is a BufferedImage):

final int rgb = i.getRGB(x, y);
if (rgb == -16777216) {
    i.setRGB(x, y, -16777216);
}

To do this, but it only replaces the pixels that are pure black with pure black.

I have also tried dimming the image, but that does not work either.

Any ideas on how I test for generic blackness?

My goal: the image I am reading is thin text. I wish to make this bolder text by this.

  • 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-06-03T04:41:57+00:00Added an answer on June 3, 2026 at 4:41 am

    The integer that you receive represents the combined red, green, blue and alpha values. Essentially, you need to:

    • break that integer down into its component red, green, blue values
    • from those values, assess the overall “brightness” of the pixel

    As a rough implementation, you could do something like this:

    int pixVal = ... getRGB() as you have
    int red = (pixVal >>> 16);
    int green = (pixVal >>> 8) & 0xff;
    int blue = pixVal & 0xff;
    int brightness = (red + green + blue) / 3;
    if (brightness < 16) {
      // pixel is black
    }
    

    Now, the value 16 is a rough value: ideally, you would tailor this to the particular image.

    Purists might also whinge that the perceived “brightness” of a pixel isn’t literally the mean of the red/green/blue pixels (because the human eye is not equally sensitive to these components). But that’s the rough idea to work from.

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

Sidebar

Related Questions

I'm looking for an algorithm that rotates an image by some degrees (input). public
I'm looking to replace MRI with JRuby for some scripts. Would it be enough
I am looking to replace a nasty shell script that uses awk to trim
I am looking for a reliable method to replace a sequence of chars in
I'm looking to replace all occurrences of space characters that follow a new line
i am looking to replace a particular image when i click on it and
I'm looking for a creative way to replace an HTML5 video with an image
I'm looking to replace an image with a class to a div with text
I'm looking from something that to replace the *parent* . %w[apple apples].each do |w|
I was looking for an algorithm to replace some content inside a list with

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.