Sorry, I am a beginner... what shall I do with this gather-circle.c?
Thank you very much for your patience.
St.
______________________________________________________________
> Od: [EMAIL PROTECTED]
> Komu: <[EMAIL PROTECTED]>
> CC: <[email protected]>
> Datum: 30.07.2007 02:40
> Předmět: Re: [GRASS-user] circle surrounding neighbors
>
>[EMAIL PROTECTED] wrote:
>
>> don't you know about any possibility to use something similar to
r.neighbors
>> but  for the circle surrounding of the pixel?
>
>Modify raster/r.neighbors/gather.c.
>
>An (untested) attempt is attached.
>
>-- 
>Glynn Clements <[EMAIL PROTECTED]>
>
>
>#include <grass/gis.h>
>#include "ncb.h"
>
>/*
>   given the starting col of the neighborhood,
>   copy the cell values from the bufs into the array of values
>   and return the number of values copied.
>*/
>
>static char **mask;
>
>static void init_mask(void)
>{
>    int i, j;
>
>    if (mask)
>       return;
>
>    mask = G_malloc(ncb.nsize * sizeof(char *));
>
>    for (i = 0; i < ncb.nsize; i++)
>       mask[i] = G_malloc(ncb.nsize);
>
>    for (i = 0; i < ncb.nsize; i++)
>       for (j = 0; j < ncb.nsize; j++)
>           mask[i][j] = sqr(i - ncb.dist) + sqr(j - ncb.dist) <= sqr(ncb.dist);
>}
>
>int gather(DCELL *values, int offset)
>{
>    int row, col;
>    int n = 0;
>
>    *values = 0;
>
>    if (!mask)
>       init_mask();
>
>    for (row = 0; row < ncb.nsize; row++)
>       for (col = 0; col < ncb.nsize; col++)
>       {
>           DCELL *c = &ncb.buf[row][offset + col];
>
>           if (!mask[row][col])
>               continue;
>
>           if (G_is_d_null_value(c))
>               G_set_d_null_value(&values[n], 1);
>           else
>               values[n] = *c;
>
>           n++;
>       }
>
>    return n ? n : -1;
>}
>
>
>

_______________________________________________
grassuser mailing list
[email protected]
http://grass.itc.it/mailman/listinfo/grassuser

Reply via email to