16bit HSV image tech - fun in 16bit!
Richard Phipps

In this thread:

There was a little discussion about using a 16bit HSV format for storing images. The general consensus seemed to be you couldn't get good results from this. Since I had some free time yesterday I worked on my own version and have the results now! I gave myself some rules first:

1) Dithering is allowed.
2) Fixed colour space, i.e. no analysing colours in the image.
3) No compression, 2 bytes per pixel.
4) Each 2 bytes contain data ONLY for that pixel.

This probably has no practical applications, but I love messing about with cool gfx stuff. :D

Ok, I've attached a little program which when unzipped will read the output.bmp file which is a 8bit image that is the same width as the original image, but has twice the height (hence 2 bytes per pixel). I've attached the program and the data image to show I didn't cheat. ;)

The program reads in the image, converts it into 32 bit values and draws it to the screen. Although not perfect, I'm pretty happy with the results! I've tried it on several types of picture and it looks good so far.

If anyone's interested then I can go into detail of how I did it.

Test image:
Original = 67690 colours
Converted = 5232 colours.



Are you still worried that people will steal your code and make millions with it?

Richard Phipps

No, the code is a total mess, but I wasn't sure if people would be bothered about this tech idea anyway. Thanks.


What's the point of this? Is it to reduce file size? In case it is, how does it compare to formats which store 32-bit data and compress it using lossless compression methods?

The girl looked good though. But I haven't got the original 32-bit image to compare with. It would be nice.

Richard Phipps

It's just a fun technical exercise. There's not any real point as it's not designed for compression. As I said it follows on from the original posts in the thread I linked too.

Sometimes it's just fun to play with different gfx ideas. :)


The bitmap image is way cooler lookin' ;)

Richard Phipps

If I'm going to do some gfx work with pictures I always prefer using a image of a good looking women. ;)

Does anyone else have any good test pictures I can use? Something with different hues, areas of high & low contrast, and degrees of saturation would be great. I'd post the resulting picture here. :)

Andrei Ellman
Richard Phipps said:

Does anyone else have any good test pictures I can use? Something with different hues, areas of high & low contrast, and degrees of saturation would be great.

Attatched is the image I used when testing the ChromaPlas screensaver (which incidentally contains some very fast fixed-point RGB<->HSV and RGB<->HLS conversion algorithms). I don't know if it is the best possible test-image for fiddling with the HSV colour-space, but it's the one I used when testing ChromaPlas.


PS. Have you also tried HLS as well as HSV? Perhaps one is better suited to low resolution channel-values than the other (although I suspect that HSV can withstand lower bit-depths better because the HSV hex-cone only has one point whereas the HLS double-hex-cone has two points).

Richard Phipps

Thanks Andrei! I'm glad someone else is interested! :)

I haven't tried HLS, though I'm already using HSV. Not sure if there would be much of a difference.

Ok. Here is the Girl picture for people who didn't look at the program. The original 24bit image is on the right and the 16bit HSV version is on the left. Although there is some loss of quality, I think it's good considering it's only 2/3rds of the original information size.


And here's the 16 bit HSV version of your picture Andrei. I shrunk it down 50% as it was a bit big for me. The original image was a bit dotty as well, but it still looks ok.
In fact it seems to cope with most colour situations pretty well.. :)



What does 16-bit RGB look like compared to the 16-bit HSV and 24-bit RGB original?

Kitty Cat

What does 16-bit HSV look like without dithering?

Richard Phipps

I've just had chance to test it. To be honest loading the image in a 16 bit mode with dithering in Allegro looks pretty similar to the HSV version. Some areas look better in 16RGB and others look a bit better in 16HSV. But overall, 16RGB looks better because of the reduced dithering.

Oh well! It was fun to play with this idea. :)

Andrei Ellman


Do you mind if I use the code in my ChromaPlas screensaver? At the moment, it only does the HSV effects using 32-bit colour, but on my todo-list is to add 16-bit colour capabilities to ChromaPlas. 16-bit HSV resolution might just be enough to not have any noticable degradation of image-quality in 16-bit modes. Currently, ChromaPlas uses 11 bits for Hue, 8 bits for Saturation, and 8 bits for value (I should really use less bits for hue than I do for value, but because of the way my algorithm works, each hexcone-segment is 8-bits, and a span of 6 8-bit segments requires 11-bits).


Richard Phipps


The 16 bit HSV format I used was designed for output in a 24/32 bit screenmode, not a 16-bit one. Is that what you are planning to do? Because if you want it for a 16-bit screenmode then it would be better redesigning a new HSV format.


Andrei Ellman

OK then, I'll experiment with my own formats for output to 16-bit displays. How many bits per H,S and V channel did you use?


PS. As for the sample image I posted earlier, it was taken in Graceland. see this post for more details.

Richard Phipps

HSV: 637 with dithering. :)

If you are outputting in 15/16 bit then you can only have 5 bits for value, so 655 might work well for you (without dithering).

Arthur Kalliokoski

Posting pictures that allegedly show how well it works is like those old TV commercials advertising TV's. "Look how clear the picture is!". You can't see it any better than your crappy old TV, snow and all.

Richard Phipps

Er.. what? If you are viewing in a 32 bit screen mode we can see the original and the new 16bit version. ???

Neil Walker

From your picture, looks like saturation is being increased too much.

Thread #587201. Printed from Allegro.cc