[GRASS-dev] some detail questions on i.segment
mlennert at club.worldonline.be
Fri Jun 3 02:19:29 PDT 2016
On 03/06/16 10:05, Markus Metz wrote:
> On Wed, Jun 1, 2016 at 2:24 PM, Moritz Lennert
> <mlennert at club.worldonline.be> wrote:
>> Another question concernant i.segment's details:
>> IIUC, the threshold used in region-growing is normalized using a common
>> denominator defined by:
>> divisor = globals->nrows + globals->ncols;
>> (BTW, why '+', not '*' ?)
> The divisor would become too large and the adjustment would have no effect.
>> Row and column numbers come from
>> globals->nrows = Rast_window_rows();
>> globals->ncols = Rast_window_cols();
>> The threshold is then adjusted to take into account object size, i.e. to
>> favor merging of smaller regions compared to merging of larger regions:
>> adjthresh = pow(alpha2, 1. + (double) smaller / divisor);
>> It is this adjusted threshold that is used to decide whether to merge
>> regions or not, depending on whether their similarity is smaller than this
>> adjusted threshold or not.:
>> if (compare_double(Ri_similarity, adjthresh) == -1)
>> Ri_similarity is normalized by
>> val /= globals->max_diff;
>> where globals->max_diff is defined as the difference between max anf min
>> values in the input file, as obtained by
>> Rast_get_fp_range_min_max(&(fp_range[n]), &min[n], &max[n]);
>> I hope that I've understood all of this correctly.
>> Now my question:
>> Are nrows and ncols region-dependent, i.e. will the divisor in the
>> calculation of the adjusted vary depending on the region I defined ?
> Yes, nrows and ncols come from the current region.
>> And max->diff do I understand correctly that Rast_get_fp_range_min_max() is
>> region-independent, i.e. that if I take different regions of the same image,
>> I will always get the same max_diff ?
> Yes, this way you can test settings on a small region before applying
> them to a larger region.
>> If this is correct, does this mean the region size might determine whether
>> some objects (or pixels) are merged or not ?
> Yes. In effect, the computational region size determines whether an
> object is large or small.
>> This would put into question the determination of a good threshold by
>> testing on small regions as the same threshold might not have the same
>> effect in larger regions, or ?
> Indeed. There are no comments in the code (apart from "TODO: better")
> explaining the reason for this adjustment. In theory it makes sense to
> me to favour merging of smaller regions, or more precisely, to avoid
> merging of larger regions.
I completely agree with this approach.
> "Small" and "large" depend on the
> computational region. When testing for the previous GSoC project on
> i.segment, I did not notice drastic differences when changing the
> computational region.
I would imagine that differences are not dramatic, but we will test
this, here. But maybe an option would be to use the number of rows and
cols in the entire image as divisor, not the current region's ?
More information about the grass-dev