[GRASSLIST:3618] Re: function to compare rasters visually

Glynn Clements glynn.clements at virgin.net
Mon Jun 7 18:47:59 EDT 2004


Benjamin Ducke wrote:

> Dissolve seems to be what graphics programs like
> Photoshop call "transparency" and is usually
> implemented using an alpha blending.
> It should not be too hard to implement something
> like this in a GRASS rast module.
> The Open Source program Gimp (www.gimp.org) should have all
> the necessary algorithms.
> Also, Graphics Gems (Vol. I) has an alpha blending algorithm.
> I would like to see something like this in a GRASS module,
> but I really think alpha blending should be done by adding the
> needed functionality to d.rast. Maybe one could add an integer
> 1..100 to the '-o' parameter to specifiy the strength of
> transparency?
> While we are at it: I would love to see antialiasing for
> vector maps (d.vect), it makes them so much easier on the eyes.
> Are there any capabale graphics programmers who would implement it
> (come on - shouldn't be that hard) ?

GRASS' display architecture doesn't support translucency, so you can't
blend with what is already on the monitor.

If you want a blend between two maps, you have to rasterise both,
blend the results yourself, then draw the blended result. E.g.

	#!/bin/sh
	# Usage: d.blend.sh <map1> <k1> <map2> <k2>
	map1="$1"
	k1=$2
	map2="$3"
	k2=$4
	r.mapcalc <<EOF
	R = ($k1 * r#$map1 + $k2 * r#$map2) / ($k1 + $k2)
	G = ($k1 * g#$map1 + $k2 * g#$map2) / ($k1 + $k2)
	B = ($k1 * b#$map1 + $k2 * b#$map2) / ($k1 + $k2)
	EOF
	r.colors R color=rules <<EOF
	0 black
	255 white
	EOF
	r.colors G rast=R
	r.colors B rast=R
	r.composite r_map=R g_map=G b_map=B output=blend
	d.rast blend
	g.remove rast=R,G,B,blend

-- 
Glynn Clements <glynn.clements at virgin.net>




More information about the grass-user mailing list