[GRASS-dev] i.segment: invalid region id 0
Pietro
peter.zamb at gmail.com
Wed Jul 31 06:02:06 PDT 2013
Hi,
On Wed, Jul 31, 2013 at 12:39 PM, Moritz Lennert
<mlennert at club.worldonline.be> wrote:
>> ok, I can do it... which name should I use for the hierarchical module?
>
> i.segment.hierarchical ?
I change my mind...
Do we really need to make a module only to avoid the user to define a cycle?
>From my point of view we should avoid to bloat the GRASS' code with
this kind of codes
the code to do this operation is:
{{{
from __future__ import print_function
import time
from grass.pygrass.modules import Module
def segment(thresholds, output='seg__%.2f', **opts):
iseg = Module('i.segment')
seeds = None
for thr in thresholds:
opts['threshold'] = thr
opts['seeds'] = seeds
opts['output'] = output % thr
st = time.time()
iseg(**opts)
print("%s, required: %.2fs" % (opts['output'], time.time() - st))
seeds = opts['output']
# use the function
segment([0.02, 0.05, 0.1],
group='rgb', method='region_growing', similarity='euclidean',
minsize=2, iterations=20, overwrite=True)
}}}
and the output will be something like:
{{{
100%
seg__0.02, required: 15.02s
100%
seg__0.05, required: 7.82s
100%
seg__0.10, required: 9.99s
}}}
Best regards
Pietro
More information about the grass-dev
mailing list