CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
  1. #16
    Join Date
    Sep 2002
    Location
    DC Metro Area, USA
    Posts
    1,509
    But if the user has an 8-bit paletted display, then (assuming you respond to the various palette-realted messages like WM_QUERYNEWPALETTE) the image is displayed using your palette. It's the Window's palette mapper that's responsible for deciding which color in the palette is closest to a particular color in your full-color original.
    I'm semi-with you on the just having one source, But I totally disagree on the "Window's palette mapper" even half-way producing a remotely acceptable image with out some sort of dither, espcially with several different images. Having made such a strong statement, I will now proceed to waffle ! Concievablely, given a set of images with a fairly similiar set of colors, you might get a reasonable image. However, for most images you will get a far superior image if you do a Floyd-Steinberg dither (potentially better with more complex dithers, but that's debatable). The trade off is image quality vs speed (startup) vs space. You could try just using the 24-bit images, and the palette (my bet is noticably poor 8 bit quality) - 2nd least storage requirements; dither and just use the resulting 8 bit images - least space intensive but not as good 24 bit quality, or dither on the fly - combo of the first two, but depending on the image size, slower on startup.
    bytz
    --This signature left intentionally blank--

  2. #17
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556
    I think your analysis of image quality vs startup speed vs space is exactly on point. I also agree that the Windows palette manager stinks when it comes to selecting a palette color for rendering of a 24-bit color. For one thing, it determines color "closeness" in RGB space which isn't even close to a perceptual color space. For another, the "closeness" calculation is a simple "city block" algorithm that sums absolute values of RGB differences; i.e., it's not even a Euclidiean distance.

    (In it's defense, MS says the palette manager is fast and "surprisingly good" -- I think that's a quote -- given the shortcuts that were taken.)

    A dithered image would clearly give better 8-bit results than reliance on the palette manager. But in the end analysis, I'm not sure that the result would be worth the effort, for the reason that a user of an 8-bit display already expects images that are not all that good in color fidelity. He probably would be very pleased with the results obtained with a customized palette, even one that's applied in common over several different images, since he's probably accustomed to lousy images from other apps.

    -Mike

    PS: Nice to see someone referring to Floyd-Steinberg here, particularly since that process is most commonly applied in printouts, not displays. Of course it's perfectly adapted for use in displays; I just don't see it used much. For my part, I really like Eschbach's improvement (I think it was Eschbach, it might have been Ulichney) which uses a blue noise mask for calculation of the threshold matrix. It seems to give superior results with fewer artifacts in the dithered result, with almost no time penalty (only a memory penalty since the threshold is no longer constant). There's a lot of good articles out there on the topic. I just came across http://citeseer.nj.nec.com/ostromoukhov01simple.html "A Simple and Efficient Error-Diffusion Algorithm", Victor Ostromoukhov (2001)

  3. #18
    Join Date
    Sep 2002
    Location
    DC Metro Area, USA
    Posts
    1,509
    Cool comment about " Eschbach's improvement" I had not run across it yet...

    I would tend to disagree with your previous comments though. I'm not convinced that in 8bit land that the palette manager chooses a palette, rather I believe (of course, you know easily some beliefs are disproven ) that the palette manager maps the color to a "close" one in the palette. And even more so I'd really disagree with
    But in the end analysis, I'm not sure that the result would be worth the effort, for the reason that a user of an 8-bit display already expects images that are not all that good in color fidelity
    Well, (time to waffle), when you start talking about the average user, they tend to be pretty, hmmm, thick. But show a user a non-dithered image vs a well dithered one, and they're likely to choose the dithered (highly dependant on the image of course). And granted, the better the palette is, the better both will look...
    bytz
    --This signature left intentionally blank--

  4. #19
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556
    I just came across a good article on CodeProject, that apparently does the dithering that bytz and I have been discussing, using the classes developed by Jeff Prosise in his MSDN articles.

    The link is http://www.codeproject.com/bitmap/cquantizer.asp

    The article is "Color quantization using the octree algorithm" by Davide Pizzolato

    -Mike

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured