"Dithering" again

"Dithering" again

Post by Gerald Gutierre » Sat, 26 Sep 1998 04:00:00



Quote:> Or you might be thinking of alpha-channel based processing where the two solid
> areas are in different layers, and an alpha channel determines how much a pixel
> from each layer affects the pixels near the borders of the solids areas.  I
> can't point you towards any source code implementations of this, but various
> applications support it, including Photoshop.  The alpha channels are usually
> in the form of gradients, not random noise functions.

No, I don't think so. I've been thinking about what I'm trying to do and
I've come up with a better way of describing it. I still don't know what
the term is, but I don't believe it is called dithering nor has anything
to do with alpha channels.

Let's say I have a black region and a white region in juxtapose. The
boundary is vertical, right down the middle. Let's say black is on the
left, white is on the right. I want to create a gradient effect with
only black and white. I think what I would want to do is, based on
distance from the boundary, on going left I sprinkle lesser and lesser
proportions of white on the black area, and the same with the right
side, only with black. This creates a black -> white gradient effect
with only two colors.

My context for doing this is that I have a gradient of 16 bands from
left to right. I only have those 16 colors to work with. I'd like to
make the gradient appear as smooth as possible. I'd also like to do this
on the fly as the gradient is displayed, so it would be really nice if
the algorithm is fast.

What I'd like to know is the term for this, and the technique for doing
it. If anyone can tell me what it's called and possibly where I might be
able to find such information on the Internet, it would be absolutely
great.

Thanks.


 
 
 

"Dithering" again

Post by Thomas Crul » Sun, 27 Sep 1998 04:00:00


From what i understand what you're trying to do is in fact dithering.
You can probably use floyd-steinberg error diffusion algorithm although
it does show some artifacts in some cases. I believe it is the algorithm
your old printer uses to print grayscale images with just black/white dots.

it is described in Foley-VanDam.
in a few words, here's how it works, it's pretty simple and efficient.
given a greyscale image (in your case, a gradient from black to white)
stored as an 2d array of grey value.
you approximate the greyscale value of each pixel starting from top-left to
bottom-right to the however close you want. then you compute the approximation
error you introduced (actual value - approximated value) and you diffuse it
over the neighborhing pixels you haven't processed yet (ie (x+1,y), (x-1,y-1),
(x,y-1) and (x+1,y-1)) with the following ratios respectively: 7/16, 3/16,
5/16, 1/16

i've also seen a paper on more sophisticated algorithms that give different
results but i can't remember who it's by.

      Thomas

>No, I don't think so. I've been thinking about what I'm trying to do and
>I've come up with a better way of describing it. I still don't know what
>the term is, but I don't believe it is called dithering nor has anything
>to do with alpha channels.

>Let's say I have a black region and a white region in juxtapose. The
>boundary is vertical, right down the middle. Let's say black is on the
>left, white is on the right. I want to create a gradient effect with
>only black and white. I think what I would want to do is, based on
>distance from the boundary, on going left I sprinkle lesser and lesser
>proportions of white on the black area, and the same with the right
>side, only with black. This creates a black -> white gradient effect
>with only two colors.

>My context for doing this is that I have a gradient of 16 bands from
>left to right. I only have those 16 colors to work with. I'd like to
>make the gradient appear as smooth as possible. I'd also like to do this
>on the fly as the gradient is displayed, so it would be really nice if
>the algorithm is fast.

>What I'd like to know is the term for this, and the technique for doing
>it. If anyone can tell me what it's called and possibly where I might be
>able to find such information on the Internet, it would be absolutely
>great.

>Thanks.




 
 
 

"Dithering" again

Post by Dirk Djug » Sun, 27 Sep 1998 04:00:00



>Let's say I have a black region and a white region in juxtapose. The
>boundary is vertical, right down the middle. Let's say black is on the
>left, white is on the right. I want to create a gradient effect with
>only black and white. I think what I would want to do is, based on
>distance from the boundary, on going left I sprinkle lesser and lesser
>proportions of white on the black area, and the same with the right
>side, only with black. This creates a black -> white gradient effect
>with only two colors.

>My context for doing this is that I have a gradient of 16 bands from
>left to right. I only have those 16 colors to work with. I'd like to
>make the gradient appear as smooth as possible. I'd also like to do this
>on the fly as the gradient is displayed, so it would be really nice if
>the algorithm is fast.

>What I'd like to know is the term for this, and the technique for doing
>it. If anyone can tell me what it's called and possibly where I might be
>able to find such information on the Internet, it would be absolutely
>great.

What you want to do is create a gradient image _pretending_ you have the
full range off color (make a 24 bit rgb array or whatever), and then render
it with only 2 colors, using a dither algorithm, eg. Floyd-Steinberg.
If this was using Windows you would get the dither for free with
DrawDibDraw().

Just thought it helps to make clear that it's a 2 step process.

cU
--

   http://djuga.home.ml.org
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get Retriever 2.1 now: http://retriever.home.ml.org

Shareware image viewer, thumbnailer & database
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 
 
 

"Dithering" again

Post by senec » Sat, 31 Oct 1998 04:00:00


Quote:>Let's say I have a black region and a white region in juxtapose. The
>boundary is vertical, right down the middle. Let's say black is on the
>left, white is on the right. I want to create a gradient effect with
>only black and white.
...
>What I'd like to know is the term for this, and the technique for doing
>it.

Would the optimum algorithm start at the middle and perform a weighted
average of two neighboring pixels, white and black in this case,
replace them then do two weighted averages on either side,
(one displaced) of the middle pixels replacing there
components, moving outward from there. Its simple when you know that
the edge is at the middle. If you didn't know this and started at one end
then
one half of the row would be smeared. So it seems that you would have to
edge detect first then apply your filter. But maybe instead of as (a+b)/2
you would want to do a x*a+(1-a)*y?
--Seneca
 
 
 

1. ****"""""BUG IN PROGRAM"""*****

Does anyone have a problem using PhotoShop 3.  I have alien skin filters
and Kai's Power Tools and yet if I use the spheroid designer in Kai's Power
Tools and then try to add a drop shadow to it using alien skin, PhotoShop
crashes.  Has anyone got a solution to this problem.  It's really bugging
me (pun not intentional).

Yours Pete

2. LW 5.5 release dates?...

3. """"LOOKING FOR METRAEYES MODELLER AND TURBO.PXP FOR AN EXCHANGE"""""

4. X Window programming question

5. Again, an apology for "Onyx"...

6. Micrographix (DRW) files to BMP Conversion

7. Textures with "holes" (again)

8. surface of an ellipsoid

9. Dss Satellite "HU"&"H"card programming click link

10. ***WHICH IS BEST CAPTURE"SNAPPY""AIGOTCHA"?***

11. HELP - "mli"/"mat"

12. "Fur"/"hair" texture

13. popen("gnuplot", "w")