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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:48:12+00:00 2026-05-17T15:48:12+00:00

I intend to display (4, 8 or 16 bit per channel – no alpha)

  • 0

I intend to display (4, 8 or 16 bit per channel – no alpha) images on a 1 bit display in an embedded system. Images are stored in RGB tuples. My intention is to use Floyd-Steinburg, as it looks reasonably good, is more than quick enough and concise in code.

In reference to the WikiPedia article, I have two questions.

What would the best practice for expressing nearest colour be? Would the following work? (ignore that I’m returning a structure in c)

typedef rgb16_tag { unsigned short r, g, b } rgb16;

rgb16 nearest_1bit_colour(rgb16 p) {
    double c; rgb16 r;
    c  = ((double)(p.r + p.g + p.b + 3 * (1 << 15))) / ( 3.0 * (1 << 16));
    if (c>= 1.0) { 
       r.r = r.g = r.b = 1;
    } else {
       r.r = r.g = r.b = 0;
    }
    return r;
 }

and, Is the expression of quantization error done on a per channel basis? i.e. does this make sense?

rgb16 q, new, old, image[X][Y];
int x, y;

... /* (somewhere in the nested loops) */
    old = image[x][y];
    new = nearest_1bit_colour(old);

    /* Repeat the following for each colour channel seperately. */
    q.{r,g,b} = old.{r,g,b} - new.{r,g,b};

    image[x+1][y].{r,g,b}   = image[x+1][y].{r,g,b} + 7/16 *   q.{r,g,b}
    image[x-1][y+1].{r,g,b} = image[x-1][y+1].{r,g,b} + 3/16 * q.{r,g,b}
    image[x][y+1].{r,g,b}   = image[x][y+1].{r,g,b} + 5/16 *   q.{r,g,b}
    image[x+1][y+1].{r,g,b} = image[x+1][y+1].{r,g,b} + 1/16 * q.{r,g,b}
  • 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-17T15:48:13+00:00Added an answer on May 17, 2026 at 3:48 pm

    I’ve seen two typical approaches to measuring the difference between two colors. The most common way is probably to just find the Euclidian distance between them through the color cube:

    float r = i.r - j.r;
    float g = i.g - j.g;
    float b = i.b - j.b;
    float diff = sqrtf( r * r + g + g + b * b );
    

    The other is just to average the absolute differences, possibly weighting for luminance:

    float diff = 0.30f * fabs( i.r - j.r ) +
                 0.59f * fabs( i.g - j.g ) +
                 0.11f * fabs( i.b - j.b );
    

    As to your second question, yes. Accumulate the error separately in each channel.

    Edit: Misread at first and missed that this was for a bi-level display. In that case, I’d suggest just using luminance:

    float luminance = 0.30f * p.r + 0.59f * p.g + 0.11f * p.b;
    if ( luminance > 0.5f * channelMax ) {
         // white
    } else {
         // black
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i intend to display some information when i right click on a textbox. this
How to display TabActivity in AlertDialog? I know that it's a little bit tricky,
I'd like to use Google maps static API to display a map with a
I hava a jQuery UI datepicker which I intend to use with a textbox
I intend to display some ads on the sides of my website which move
I intend to make a web application that displays 3d environments that can be
I intend to create asp.net pages using Visual Studio 2008. Preferably, the pages should
I intend notifying the user 60 seconds before the session expires in asp.net. I
I intend to make some software to be sold over internet. I've only created
I intend to share my source code on an invite-only basis to a few

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.