[GRASS-user] Extracting grey features from an image
Micha Silver
micha at arava.co.il
Thu May 27 06:38:33 EDT 2010
On 05/27/2010 12:59 PM, baobazz wrote:
> Hello
>
> I've got a black and white image with some grey features on it
>
>
> I'd like to create a new image containing only these features so I can
> vectorize them
>
> i think that I have to use
> r.mask
> r.mapcalc
> or
> r.reclass
>
> r.describe raster
> returns me
> 0-121 123 125-127 132-255
>
If I understand you correctly, you have a grey-scale raster (values from
0-255) which is displayed in three colors, black, grey and white?
From the above there are cells with values from 0-255, the only values
that do *not* appear are 122, 124, and 128-131.
Perhaps you can run r.describe -1 ( or r.stats -ap ) to output all the
categories, one per line, to have a clear idea of what the original
contains.
Now, if you need to separate out raster cells with certain category
values, then vectorize it, you could do, i.e.:
# extract only values between 125 and 127
r.mapcalc grey_raster="if(orig_rast>=125 and orig_rast<=127, 1, null() )"
# All cells from 125-127 get the value '1' in the new raster. All others
are null.
# convert to vector
r.to.vect in=grey_raster out=grey_polygons feature=area
This will clump together into a vector of polygons all raster cells that
have values 125,126, or 127.
HTH
--
Micha
> I created a mask of my image
> r.mask input=image maskcats="0 thru 121" -i
> -i to invert the maskcats range
>
> Only the grey features appear.
>
> So, my grey features seem to have the 0-121 range category of values.
>
> Considering that, how can I manage to create a raster map based only on
> these values.
>
> I used r.reclass like this:
> r.reclass input=raster output=rasterRec
>
>> 0 thru 121=1 black
>> *=NULL
>>
> But I didn't get any good result...
>
> Any help would be greatly appreciated!
>
>
>
>
--
Micha Silver
http://www.surfaces.co.il/
Arava Development Co. +972-52-3665918
More information about the grass-user
mailing list