Page 1 of 1

Convert tif, rgba16 to rgba8; Filling concaves of heightmap

Posted: 2014-03-06T04:30:56-07:00
by Chronocide
ImageMagick looks awesome and very versatile.
Two things at the moment I'm wondering if and how ImageMagick could do:
1) Convert tif, rgba16 to rgba8. There's also something about orientation involved, as flipping occurs when down-sampling with photoshop.
2) World Machine has a snow function which fills concave areas, and spills over, much as you'd expect snow to do. But it adds overflow and mounds. I'm wondering if ImageMagick could do something similar, but simplified, as if with water levels, finding brightest rings of pixels encompassing darker areas, and filling them with like brightness.

Re: Convert tif, rgba16 to rgba8; Filling concaves of height

Posted: 2014-03-06T05:41:31-07:00
by snibgo
2) Some examples might explain the concept.

Re: Convert tif, rgba16 to rgba8; Filling concaves of height

Posted: 2014-03-06T07:47:37-07:00
by Chronocide
Terrain without snow effect:
Image

With snow:
Image

Heightmap, before:
Image

After:
Image


It's snow device does snow well, but I can't get it to fill all concave areas without a bunch of overflow (it's a moderate amount in the example). I think some nice plateaus might be achieved if these concave areas could be filled to the 'brim' - the 'brim' being the brightest encircling ring of pixels, defining a region of darker pixels.
I think such a function would make lots of flat, traversable areas, at varying levels, for a somewhat noisy heightmap like that.

Re: Convert tif, rgba16 to rgba8; Filling concaves of height

Posted: 2014-03-06T10:24:14-07:00
by snibgo
Hmm, interesting problem. It really depends on the exact rules. Suppose we have a shallow basin next to a deeper basin, so there is a ridge between them. Some water (or snow) falls, so both basins have the same depth of water in them. More rain so the water levels rise until the shallow basin becomes full, level with the ridge. What happens them? Perhaps water spills over, instantly filling the deep basin. Or maybe the next rain makes no difference to the shallow basin because it is already full, so the level in only the deep basin rises.

Re: Convert tif, rgba16 to rgba8; Filling concaves of height

Posted: 2014-03-06T10:27:34-07:00
by fmw42
Imagemagick does not have a "watershed" function. It is one of the feature that did not get implemented in the -morphology function.

Re: Convert tif, rgba16 to rgba8; Filling concaves of height

Posted: 2014-03-06T10:35:25-07:00
by snibgo
A watershed function is:

Code: Select all

%IM%convert ^
  %INFILE% ^
  ( +clone ^
    -statistic NonPeak 3x3 ^
  ) ^
  -compose MinusSrc -composite ^
  -fill white +opaque black ^
  %OUTFILE%

Re: Convert tif, rgba16 to rgba8; Filling concaves of height

Posted: 2014-03-06T15:09:04-07:00
by Chronocide
"It is one of the feature that did not get implemented in the -morphology function"
Does that mean there's some un-implemented code lying around somewhere? :D


I've overlayed the result as black.
Image
That's interesting. It traced the convex edges, one pixel in width. Is that what it's supposed to do? I don't see any fill happening, and, it's a binary map.
I suppose it would be a good supply of starting points in finding areas to fill.

Re: Convert tif, rgba16 to rgba8; Filling concaves of height

Posted: 2014-03-06T15:19:04-07:00
by fmw42
"It is one of the feature that did not get implemented in the -morphology function"
Does that mean there's some un-implemented code lying around somewhere?
No, not that I know about. It just never got implemented. I suspect Anthony either did not know about that function or just never got around to it, when he build the -morphology command.

Re: Convert tif, rgba16 to rgba8; Filling concaves of height

Posted: 2014-03-06T18:50:47-07:00
by Chronocide
This watershed thing is an interesting subject. I've found it lead into image scanning of grains of rice.