by ʇolɐǝz ǝɥʇ qoq

Submit your Photo
Hall of Fame

Please participate in Meta
and help us grow.

Photography Stack Exchange is a question and answer site for professional, enthusiast and amateur photographers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am building some hardware with a graphical user interface and my images are stored with 8 bits per pixel (bpp) in RRRGGGBB format. However, my video chip expects 30bpp pixels (10 bits for each color), which leaves me with the problem of converting each channel from 3 bits (or 2 in the blue case) to 10 bits.

Because I'm building the system from scratch, I have a lot of flexibility on implementing a solution. Some possible choices are:

  • Map the original 3 bits to the 3 most significant bits of the video chip, an set the remaining bits to 0 (I suppose white would not be so white)
  • Map the original 3 bits to the 3 most significant bits of the video chip, an set the remaining bits to 1 (I suppose black would not be totally black)
  • Map each original bit (b1,b2,b3) to several bits on the video chip (e.g., b1,b1,b1,b1,b2,b2,b2,b,b3,b3) - I don't know if this makes any sense...

Is any of these approaches better than the others, or is there a more adequate solution?


share|improve this question

closed as off-topic by mattdm, Paul Cezanne, Michael Clark, AJ Henderson, cmason Sep 2 '13 at 0:01

  • This question does not appear to be about photography within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

Programmers.SE would be a much better fit for this question. General practice in this area is to repeat the pattern mapping b1,b2,b3 -> b1,b2,b3,b1,b2,b3,b1,b2,b3,b1. – James Snell Sep 1 '13 at 12:44
This question appears to be off-topic because it is about graphics programming, not photography. – mattdm Sep 1 '13 at 12:48
@mattdm, though the question is in fact about programming, the community of Photo.SE is much more able to answer it, as all the answers indicate so far. Folks here are very knowledgeale about this subject. – rick Sep 1 '13 at 21:18
Nonetheless, it's off-topic. Since many of the people here come from one of the big three sites, we tend to skew towards the tech/geek side of photography, so, sure, you get a lot of people who know the answers. I bet you could get a decent answer about many general engineering, computer science, or physics questions not related to photography. Even though that's possible, I'd like to discourage it, because it has a self-reinforcing way of skewing the site away from the broader realm of photography and just into this technical niche. – mattdm Sep 1 '13 at 21:39
up vote 1 down vote accepted

None of your three choices are the optimum. When expanding a small unsigned binary integer into a larger one, put the original bits in the high bits of the large number, then continue replicating the whole input number into the lower bits until they are filled.

For example, suppose you want to expand a 3 bits value into 8 bits, using the full dynamic range of the 8 bit number but spreading the 8 possible input values accross that range as best as possible. Let's say the the original bits of the 3-bit input number are ABC. The best expanded 8 bit number given the above constraints would be ABCABCAB.

share|improve this answer

This is probably not strictly on-topic in Photo.SE. That said, you'll probably want to interpolate. You have the range [0, 7] representable with three bits, and you want to stretch it so that 0 stays 0 but 7 is mapped to 1023 (the maximum value representable with ten bits). Assuming linear interpolation, you can compute the corresponding 10-bit value from a 3-bit value as follows:

v10bit = v3bit * 1023 / 7

share|improve this answer

Yeah, off topic and interpolation is the way to go, but I think you might get better results by using adjacent pixels in your interpretation. Use the N,S,E, and W pixels with one weighting and the NE, SE, NW and SW pixels with a lower weighting, probably something to do with the square root of 2.

Google around for Pirsh prediction, maybe some of the math will help you there.

Stil, the results aren't going to be that great.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.