[vwnc] Converting a 32bit screen capture image into a GIF ...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[vwnc] Converting a 32bit screen capture image into a GIF ...

Dennis smith-4
(VW7.4.1)

Converting a depth 32 image into a GIF (8 bit) really damages the colour.
If the conversion is changed from using NearestPaint to OrderedDither the
actual colours are pretty good except for the speckled result presumably
caused
by the dither.

Has anyone done anything that improves this??

--
Dennis Smith                         +1 416.798.7948
Cherniak Software Development Corporation   Fax: +1 416.798.0948
509-2001 Sheppard Avenue East        [hidden email]
Toronto, ON M2J 4Z8              sip:[hidden email]
Canada         http://www.CherniakSoftware.com
Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Converting a 32bit screen capture image into a GIF ...

Wallen, David
Offhand, I don't remember how to do this with VW, but the results should
look okay as long as you first prepare a customized palette for the
original image I.e., reduce the original colors to a best-matching set
of 256 colors. There are various algorithms to do this. Some favor the
most numerous colors, giving as large a representative set as possible
for the dominant colors. Others strive for the best overall coverage.
And so on.

- Dave

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On
Behalf
> Of Dennis Smith
> Sent: Tuesday, April 01, 2008 11:57 AM
> To: VWNC,
> Subject: [vwnc] Converting a 32bit screen capture image into a GIF ...
>
> (VW7.4.1)
>
> Converting a depth 32 image into a GIF (8 bit) really damages the
colour.
> If the conversion is changed from using NearestPaint to OrderedDither
the
> actual colours are pretty good except for the speckled result
presumably

> caused
> by the dither.
>
> Has anyone done anything that improves this??
>
> --
> Dennis Smith                         +1 416.798.7948
> Cherniak Software Development Corporation   Fax: +1 416.798.0948
> 509-2001 Sheppard Avenue East        [hidden email]
> Toronto, ON M2J 4Z8              sip:[hidden email]
> Canada         http://www.CherniakSoftware.com
> Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Converting a 32bit screen capture image into a GIF ...

Dennis smith-4


Wallen, David wrote:
Offhand, I don't remember how to do this with VW, but the results should
look okay as long as you first prepare a customized palette for the
original image I.e., reduce the original colors to a best-matching set
of 256 colors. There are various algorithms to do this. Some favor the
most numerous colors, giving as large a representative set as possible
for the dominant colors. Others strive for the best overall coverage.
And so on.
  
Actually I was able to do this by creating a new method in image to convert to a palette
based on reducing the list of uniqueColors by discarding those close to each other.
By tuning the comparison I reduced it to an 8bit depth image which looked identical to the
original 32 bit image -- then converting to a GIF did not lose anything!!!!

Thanks for the suggestion.
- Dave

  
-----Original Message-----
From: [hidden email] [[hidden email]] On
    
Behalf
  
Of Dennis Smith
Sent: Tuesday, April 01, 2008 11:57 AM
To: VWNC,
Subject: [vwnc] Converting a 32bit screen capture image into a GIF ...

(VW7.4.1)

Converting a depth 32 image into a GIF (8 bit) really damages the
    
colour.
  
If the conversion is changed from using NearestPaint to OrderedDither
    
the
  
actual colours are pretty good except for the speckled result
    
presumably
  
caused
by the dither.

Has anyone done anything that improves this??

--
Dennis Smith                 		         +1 416.798.7948
Cherniak Software Development Corporation   Fax: +1 416.798.0948
509-2001 Sheppard Avenue East        [hidden email]
Toronto, ON M2J 4Z8              <a class="moz-txt-link-freetext" href="sip:dennis@CherniakSoftware.com">sip:dennis@...
Canada			         http://www.CherniakSoftware.com
Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
    

-- 
Dennis Smith                 		         +1 416.798.7948
Cherniak Software Development Corporation   Fax: +1 416.798.0948
509-2001 Sheppard Avenue East        [hidden email]
Toronto, ON M2J 4Z8              <a class="moz-txt-link-freetext" href="sip:dennis@CherniakSoftware.com">sip:dennis@...
Canada			         http://www.CherniakSoftware.com
Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Converting a 32bit screen capture image into a GIF ...

Andres Valloud-6
In reply to this post by Dennis smith-4
Dennis,

At one point I implemented Heckbert Quantization for this particular
purpose.  The results are usually very good without dithering.  This is
probably similar to what you did.  Basically, Heckbert Quantization is a
median cut algorithm... so...

0.  If the amount of unique colors is not greater than the amount of
target colors, skip the following altogether.

1.  Put all unique colors in the image inside a box.

2.  amountOfTargetColors timesRepeat:

2a.  Select the box with the largest span in any dimension (R, G or B).

2b.  Split the box selected in step 2 at the median (not average!) point
of the largest span.  This creates 2 new boxes, each of which has half
the colors of the original one.  [note: "flat boxes" such as planes and
lines have to be handled correctly, this can be somewhat tricky]

3.  For each of the resulting boxes, calculate the average of all the
colors still inside them.  These are the representative colors for each
box.

4.  Replace all colors in the image with their representative.

This is related to hashing because, in a way, each box becomes a "hash
bucket" of sorts for the colors.  The "hash value" would be the
representative color.

Hopefully this helps...

Andres.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On
Behalf Of Dennis Smith
Sent: Tuesday, April 01, 2008 11:57 AM
To: VWNC,
Subject: [vwnc] Converting a 32bit screen capture image into a GIF ...

(VW7.4.1)

Converting a depth 32 image into a GIF (8 bit) really damages the
colour.
If the conversion is changed from using NearestPaint to OrderedDither
the actual colours are pretty good except for the speckled result
presumably caused by the dither.

Has anyone done anything that improves this??

--
Dennis Smith                         +1 416.798.7948
Cherniak Software Development Corporation   Fax: +1 416.798.0948
509-2001 Sheppard Avenue East        [hidden email]
Toronto, ON M2J 4Z8              sip:[hidden email]
Canada         http://www.CherniakSoftware.com
Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Converting a 32bit screen capture image into a GIF ...

Andres Valloud-6
Oh... I forgot to mention I still have the sourcecode for this.  If
anybody is interested, please let me know.

Andres.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On
Behalf Of Valloud, Andres
Sent: Tuesday, April 01, 2008 1:07 PM
To: [hidden email]
Subject: Re: [vwnc] Converting a 32bit screen capture image into a GIF
...

Dennis,

At one point I implemented Heckbert Quantization for this particular
purpose.  The results are usually very good without dithering.  This is
probably similar to what you did.  Basically, Heckbert Quantization is a
median cut algorithm... so...

0.  If the amount of unique colors is not greater than the amount of
target colors, skip the following altogether.

1.  Put all unique colors in the image inside a box.

2.  amountOfTargetColors timesRepeat:

2a.  Select the box with the largest span in any dimension (R, G or B).

2b.  Split the box selected in step 2 at the median (not average!) point
of the largest span.  This creates 2 new boxes, each of which has half
the colors of the original one.  [note: "flat boxes" such as planes and
lines have to be handled correctly, this can be somewhat tricky]

3.  For each of the resulting boxes, calculate the average of all the
colors still inside them.  These are the representative colors for each
box.

4.  Replace all colors in the image with their representative.

This is related to hashing because, in a way, each box becomes a "hash
bucket" of sorts for the colors.  The "hash value" would be the
representative color.

Hopefully this helps...

Andres.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On
Behalf Of Dennis Smith
Sent: Tuesday, April 01, 2008 11:57 AM
To: VWNC,
Subject: [vwnc] Converting a 32bit screen capture image into a GIF ...

(VW7.4.1)

Converting a depth 32 image into a GIF (8 bit) really damages the
colour.
If the conversion is changed from using NearestPaint to OrderedDither
the actual colours are pretty good except for the speckled result
presumably caused by the dither.

Has anyone done anything that improves this??

--
Dennis Smith                         +1 416.798.7948
Cherniak Software Development Corporation   Fax: +1 416.798.0948
509-2001 Sheppard Avenue East        [hidden email]
Toronto, ON M2J 4Z8              sip:[hidden email]
Canada         http://www.CherniakSoftware.com
Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Converting a 32bit screen capture image into a GIF ...

Andre Schnoor
In reply to this post by Dennis smith-4
Hi Denis,

here's a very simple, yet effective solution. The algorithm sorts all  
colors by hue and luminance and incrementally drops very close  
neighbors from the collection until the number of colors fits. The  
algorithm could be improved by preferring most frequently used colors  
(i.e. those filling larger areas).

I'm using it for screenshots and it does its job quite well so far.

HTH
Andre


Image>>uniqueColorValues: anInteger
        "Answer an Array of the receiver's colors limited to the argument  
size."
        | cols recent minGap minIndex i d protect |
        protect := ColorValue white.
        cols := self uniqueColorValues asSortedCollection asOrderedCollection.
        [ cols size > anInteger ] whileTrue:[
                recent := minGap := minIndex := nil.
                i := 0.
                cols do:[ :c |
                        i := i + 1.
                        recent notNil ifTrue:[
                                d := recent distanceFrom: c.
                                (minGap isNil or:[ d < minGap ])
                                        ifTrue:[
                                                c = protect ifFalse:[
                                                        minGap := d. minIndex := i ]]].
                        recent := c.
                ].
                cols removeIndex: minIndex.
        ].
        ^cols

Image>>screenShot: aFilename
        | pal img |
        pal := MappedPalette withColors: (self uniqueColorValues: 255) asArray.
        img := self convertToPalette: pal.
        ArborGIFReaderWriter putImage: img onFileNamed: aFilename.

ColorValue>> <= aColorValue
        ^self valueOrder <= aColorValue valueOrder

ColorValue>>valueOrder
        "Used for sorting colors"
        ^self hue * 100 + self luminance


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Converting a 32bit screen capture image into a GIF ...

Dennis smith-4
Thanks -- in fact after my posts I dug this up in some saved postings from
a while back and it does seem to work pretty well -- thanks.

Andre Schnoor wrote:

> Hi Denis,
>
> here's a very simple, yet effective solution. The algorithm sorts all
> colors by hue and luminance and incrementally drops very close
> neighbors from the collection until the number of colors fits. The
> algorithm could be improved by preferring most frequently used colors
> (i.e. those filling larger areas).
>
> I'm using it for screenshots and it does its job quite well so far.
>
> HTH
> Andre
>
>
> Image>>uniqueColorValues: anInteger
>     "Answer an Array of the receiver's colors limited to the argument
> size."
>     | cols recent minGap minIndex i d protect |
>     protect := ColorValue white.
>     cols := self uniqueColorValues asSortedCollection
> asOrderedCollection.
>     [ cols size > anInteger ] whileTrue:[
>         recent := minGap := minIndex := nil.
>         i := 0.      
>         cols do:[ :c |
>             i := i + 1.
>             recent notNil ifTrue:[
>                 d := recent distanceFrom: c.
>                 (minGap isNil or:[ d < minGap ])
>                     ifTrue:[
>                         c = protect ifFalse:[
>                             minGap := d. minIndex := i ]]].
>             recent := c.
>         ].
>         cols removeIndex: minIndex.
>     ].
>     ^cols
>
> Image>>screenShot: aFilename
>     | pal img |
>     pal := MappedPalette withColors: (self uniqueColorValues: 255)
> asArray.
>     img := self convertToPalette: pal.
>     ArborGIFReaderWriter putImage: img onFileNamed: aFilename.
>
> ColorValue>> <= aColorValue
>     ^self valueOrder <= aColorValue valueOrder
>
> ColorValue>>valueOrder
>     "Used for sorting colors"
>     ^self hue * 100 + self luminance
>
>

--
Dennis Smith                         +1 416.798.7948
Cherniak Software Development Corporation   Fax: +1 416.798.0948
509-2001 Sheppard Avenue East        [hidden email]
Toronto, ON M2J 4Z8              sip:[hidden email]
Canada         http://www.CherniakSoftware.com
Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc