[GRASS-user] Performing a Maximum Likelihood Supervised classification with a single band

I'd like to use i.class and i.maxlik to perform a supervised classification
of my image. However, it seems i.class only accepts image gropous with more
than one band. Is there a way or an alternative I can perform such analysis
with a single band? Thanks in advance.

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Performing-a-Maximum-Likelihood-Supervised-classification-with-a-single-band-tp5228777.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Ciao Umberto,

AFAIK, classification is multivariate on its statistical basis, so that’s why it will only take a group as input. If you only have one band, you may want to extract some information from it, for example by using r.texture module [1]. With those resulting new bands and the original one you can create then a group and perform the classification you prefer.

HTH! Cheers,

Vero

[1] https://grass.osgeo.org/grass71/manuals/r.texture.html

···

2015-10-08 10:53 GMT-03:00 umberto.minora <umberto.minora@unimi.it>:

I’d like to use i.class and i.maxlik to perform a supervised classification
of my image. However, it seems i.class only accepts image gropous with more
than one band. Is there a way or an alternative I can perform such analysis
with a single band? Thanks in advance.


View this message in context: http://osgeo-org.1560.x6.nabble.com/Performing-a-Maximum-Likelihood-Supervised-classification-with-a-single-band-tp5228777.html
Sent from the Grass - Users mailing list archive at Nabble.com.


grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

* Veronica Andreo:

Ciao Umberto,

AFAIK, classification is multivariate on its statistical basis, so that's
why it will only take a group as input. If you only have one band, you may
want to extract some information from it, for example by using r.texture
module [1]. With those resulting new bands and the original one you can
create then a group and perform the classification you prefer.
[1] https://grass.osgeo.org/grass71/manuals/r.texture.html

Ciao Vero. There is, for example, the ISODATA algorithm out there.
Just not in GRASS (yet?).

Nikos

Ciao Nikos :slight_smile:

Yes, you are right! I missed that one!

There’s ISODATA unsupervised classification algorithm (not in GRASS that I know) and it allows for just one band input.

Cheers,
Vero

···

2015-10-08 16:52 GMT-03:00 Nikos Alexandris <nik@nikosalexandris.net>:

  • Veronica Andreo:

Ciao Umberto,

AFAIK, classification is multivariate on its statistical basis, so that’s
why it will only take a group as input. If you only have one band, you may
want to extract some information from it, for example by using r.texture
module [1]. With those resulting new bands and the original one you can
create then a group and perform the classification you prefer.
[1] https://grass.osgeo.org/grass71/manuals/r.texture.html

Ciao Vero. There is, for example, the ISODATA algorithm out there.
Just not in GRASS (yet?).

Nikos

Ciao Veronica,

thanks for the hint and sorry for the late feedback.
I’d like to use GRASS so I might go for the “r.texture” solution. Anyway, I did not get how to use it for my scope.
First of all, as I already have training areas, i want to use them in a Supervised classification rather than an unsupervised one (as ISODATA).
Second, I am only interested in using one band for the classification, which was the reason I could not use “i.maxlik”.
Now, as I understand, using “r.texture” will generate images with textural features from my single band raster map. I got that I could use these as the needed input for the “i.maxlik”, but I did not get what “r.texture” will give me, and if that is going to be a good statistic sample for the Supervised. Moreover, which method would you suggest?
I am pretty new to this function, so I hope you (or anyone else) could give me a hand to better understand it.
Thanks in advance!

···

Il 08/10/2015 22:21, Veronica Andreo ha scritto:

Ciao Nikos :slight_smile:

Yes, you are right! I missed that one!

There’s ISODATA unsupervised classification algorithm (not in GRASS that I know) and it allows for just one band input.

Cheers,
Vero

2015-10-08 16:52 GMT-03:00 Nikos Alexandris <nik@nikosalexandris.net>:

  • Veronica Andreo:

Ciao Umberto,

AFAIK, classification is multivariate on its statistical basis, so that’s
why it will only take a group as input. If you only have one band, you may
want to extract some information from it, for example by using r.texture
module [1]. With those resulting new bands and the original one you can
create then a group and perform the classification you prefer.
[1] https://grass.osgeo.org/grass71/manuals/r.texture.html

Ciao Vero. There is, for example, the ISODATA algorithm out there.
Just not in GRASS (yet?).

Nikos

Ciao Umberto,

2015-10-13 10:35 GMT-03:00 umberto.minora <umberto.minora@unimi.it>:

···

Ciao Veronica,

thanks for the hint and sorry for the late feedback.
I’d like to use GRASS so I might go for the “r.texture” solution. Anyway, I did not get how to use it for my scope.

What r.texture does is to extract different texture measures from a raster map, creating several other raster maps that you can then use as extra information (derived from the original map) for the classification.

First of all, as I already have training areas, i want to use them in a Supervised classification rather than an unsupervised one (as ISODATA).
Second, I am only interested in using one band for the classification, which was the reason I could not use “i.maxlik”.
Now, as I understand, using “r.texture” will generate images with textural features from my single band raster map. I got that I could use these as the needed input for the “i.maxlik”, but I did not get what “r.texture” will give me, and if that is going to be a good statistic sample for the Supervised.

Well, I don’t know either :slight_smile: That will depend on the image, it’s resolution, and the features of the area you are studying, i guess… I’m afraid you will have to try… :stuck_out_tongue:

Moreover, which method would you suggest?
I am pretty new to this function, so I hope you (or anyone else) could give me a hand to better understand it.
Thanks in advance!

I haven’t done myself a classification in GRASS, but here is a nice tutorial you may start with: https://grasswiki.osgeo.org/wiki/Image_classification

Cheers,
Vero

Umberto:

First of all, as I already have training areas, i want to use them in a
> Supervised classification rather than an unsupervised one (as ISODATA).

Having already (well defined) training areas is a big step.

> Second, I am only interested in using one band for the classification,

Interested or restricted? If more bands are available, and you go the
supervised way, why opting for a single-band-based process? Many would
rather advise for a segmentation process (aka object-based approach).
Of course, to second Veronica, it depends on what the "source"
resolution is and what the features of interest are.

> which was the reason I could not use "i.maxlik".

Don't hesitate to experiment with the same band twice, I'd say (again).

Nikos

Thanks Nikos,

Well, actually my training areas are defined as they need to be specific features in my location (rock glaciers). I would like to use i.maxlik to classify the other pixels of my image (other than rock glaciers, alias my training areas). They should be classified as “similar” to my training areas with a certain degree (a certain likelihood). The fact I am only using one band is driven by the fact that only band 4 of Landsat 7 reflectances shows significant difference in value in my training areas than the other unclassified areas. Using twice the same band (band 4) is fine, but I am having difficulties in grouping the same band. Using i.group for instance recognizes that the map is the same and does not add it twice to the group, therefore I cannot use i.maxlik.
I don’t know if producing textures is the way to go in my case, but I will give this a try before rejecting this option. First, however, I need to study this function output.
Meanwhile, many thanks to both of you (Veronoca and Nikos)! If you have any other useful idea, I will consider them as well.

Umberto

Il 14/10/15 01:48, Nikos Alexandris nik@nikosalexandris.net ha scritto:

Umberto:

First of all, as I already have training areas, i want to use them in a

Supervised classification rather than an unsupervised one (as ISODATA).

Having already (well defined) training areas is a big step.

Second, I am only interested in using one band for the classification,

Interested or restricted? If more bands are available, and you go the
supervised way, why opting for a single-band-based process? Many would
rather advise for a segmentation process (aka object-based approach).
Of course, to second Veronica, it depends on what the “source”
resolution is and what the features of interest are.

which was the reason I could not use “i.maxlik”.

Don’t hesitate to experiment with the same band twice, I’d say (again).

Nikos

On 14/10/15 14:20, Umberto Filippo Minora wrote:

Thanks Nikos,

Well, actually my training areas are defined as they need to be specific
features in my location (rock glaciers). I would like to use i.maxlik to
classify the other pixels of my image (other than rock glaciers, alias
my training areas). They should be classified as "similar" to my
training areas with a certain degree (a certain likelihood). The fact I
am only using one band is driven by the fact that only band 4 of Landsat
7 reflectances shows significant difference in value in my training
areas than the other unclassified areas. Using twice the same band (band
4) is fine, but I am having difficulties in grouping the same band.
Using i.group for instance recognizes that the map is the same and does
not add it twice to the group, therefore I cannot use i.maxlik.
I don't know if producing textures is the way to go in my case, but I
will give this a try before rejecting this option. First, however, I
need to study this function output.
Meanwhile, many thanks to both of you (Veronoca and Nikos)! If you have
any other useful idea, I will consider them as well.

If you only work with one band, you could use your training areas to define the mean value and standard deviation in band 4 that corresponds to your class of interest and then just use r.recode to classify your image with something like this:

mean-stddev:mean+stddev:1
*:0

Obviously you can play around with the stddev value and see if it should be 1 stddev, 1/2 stddev, 2 stddev, etc, depending on your desired confidence level. Obviously this all only holds if your distribution is normal, but then again AFAIU that's the basic underpinning if maximum likelihood.

However, even though you might not observe significant differences in values between sites in individual bands, you might have significant differences in the combination of bands. With that in mind, it still might be worthwile to try your classification with several bands. At least bands 2,3 and 5 might be interesting to add as they are used in ice and snow indices...

Moritz

Thank you Moritz,

I am aware that the combination of different bands might lead to a significant difference, not detectable comparing them one against one at a time. I think this can be the case where two or more bands are correlated to each other for specific sites (eg. my training areas), but I am not an expert in statistics so please forgive me if I am wrong. However, I performed a PCA and I saw that this might not be the case. Moreover, I masked all the features in my image other than “soil” (I masked clouds, snow, water, ice, etc.) to exclude them from the classification. Indeed, my scope is to use the reflectance of the rock glacier areas (my training areas) to find similar values as a proxy of permafrost presence over the unmasked pixels of my image.
In the light of such, I think I would rather use “r.texture” as Veronica suggested to perform “i.maxlik”, OR your suggestion about using the statistics of the reflectance pixels in band 4 in my training areas with r.recode.
Thanks for all for your useful suggestions, which brought me to a next step of my work!

Il 14/10/15 14:54, Moritz Lennert mlennert@club.worldonline.be ha scritto:

On 14/10/15 14:20, Umberto Filippo Minora wrote:

Thanks Nikos,

Well, actually my training areas are defined as they need to be specific
features in my location (rock glaciers). I would like to use i.maxlik to
classify the other pixels of my image (other than rock glaciers, alias
my training areas). They should be classified as “similar” to my
training areas with a certain degree (a certain likelihood). The fact I
am only using one band is driven by the fact that only band 4 of Landsat
7 reflectances shows significant difference in value in my training
areas than the other unclassified areas. Using twice the same band (band
4) is fine, but I am having difficulties in grouping the same band.
Using i.group for instance recognizes that the map is the same and does
not add it twice to the group, therefore I cannot use i.maxlik.
I don’t know if producing textures is the way to go in my case, but I
will give this a try before rejecting this option. First, however, I
need to study this function output.
Meanwhile, many thanks to both of you (Veronoca and Nikos)! If you have
any other useful idea, I will consider them as well.

If you only work with one band, you could use your training areas to define the mean value and standard deviation in band 4 that corresponds to your class of interest and then just use r.recode to classify your image with something like this:

mean-stddev:mean+stddev:1
*:0

Obviously you can play around with the stddev value and see if it should be 1 stddev, 1/2 stddev, 2 stddev, etc, depending on your desired confidence level. Obviously this all only holds if your distribution is normal, but then again AFAIU that’s the basic underpinning if maximum likelihood.

However, even though you might not observe significant differences in values between sites in individual bands, you might have significant differences in the combination of bands. With that in mind, it still might be worthwile to try your classification with several bands. At least bands 2,3 and 5 might be interesting to add as they are used in ice and snow indices…

Moritz

* Umberto Filippo Minora <umberto.minora@unimi.it> [2015-10-14 14:20:26 +0200]:

Thanks Nikos,

Well, actually my training areas are defined as they need to be specific features in my location (rock glaciers). I would like to use i.maxlik to classify the other pixels of my image (other than rock glaciers, alias my training areas). They should be classified as "similar" to my training areas with a certain degree (a certain likelihood). The fact I am only using one band is driven by the fact that only band 4 of Landsat 7 reflectances shows significant difference in value in my training areas than the other unclassified areas. Using twice the same band (band 4) is fine, but I am having difficulties in grouping the same band. Using i.group for instance recognizes that the map is the same and does not add it twice to the group, therefore I cannot use i.maxlik.
I don't know if producing textures is the way to go in my case, but I will give this a try before rejecting this option. First, however, I need to study this function output.
Meanwhile, many thanks to both of you (Veronoca and Nikos)! If you have any other useful idea, I will consider them as well.

Umberto,

I am really sorry for not having with me the old project where I did
that, almost. I recall using the NDVI and as a second input either the
Red or the NIR band. I think the NIR it was. And, it worked for me
back then.

I don't have the time to re-create it, or test it properly. You may
want to fool GRASS by just feeding a copy of the same band, yet with
another name (?).

If you are not bound to use GRASS only, you could check for (open)
alternatives. There is a comment in
http://gis.stackexchange.com/questions/112544/isodata-classifier-in-qgis
which might be of your interest.

Otherwise, Veronica's suggestion to use an artificial band derived from
your source, is valid as well, me thinks.

Or, alongside the original band, you could use segments filled with
various stats? I mean to perform a segmentation (experimenting with the
parameters) and see if you can get segments that serve the distinction
of your wanted objects well.

There is a bullet in i.segment's manual that reads:

"Providing updates to i.maxlik to ensure the segmentation output can be
used as input for the existing classification functionality.". Don't
know if there is something new regarding this.

So, in any case, the options are many and I am sure there is a good and
effective path to get what you are seeking for.

Nikos

Umberto

Il 14/10/15 01:48, Nikos Alexandris <nik@nikosalexandris.net> ha scritto:
>
> Umberto:
>
> > First of all, as I already have training areas, i want to use them in a
> > > Supervised classification rather than an unsupervised one (as ISODATA).
>
> Having already (well defined) training areas is a big step.
>
>
> > > Second, I am only interested in using one band for the classification,
>
> Interested or restricted? If more bands are available, and you go the
> supervised way, why opting for a single-band-based process? Many would
> rather advise for a segmentation process (aka object-based approach).
> Of course, to second Veronica, it depends on what the "source"
> resolution is and what the features of interest are.
>
>
> > > which was the reason I could not use "i.maxlik".
>
> Don't hesitate to experiment with the same band twice, I'd say (again).
>
> Nikos
>

--
Nikos Alexandris | Remote Sensing Scientist, Dr
Themidos 3, 42100, Trikala, Greece
GPG Key Fingerprint 6F9D4506F3CA28380974D31A9053534B693C4FB3

Umberto Filippo Minora wrote:

> Well, actually my training areas are defined as they need to be specific
> features in my location (rock glaciers). I would like to use i.maxlik to
> classify the other pixels of my image (other than rock glaciers, alias
> my training areas). They should be classified as "similar" to my
> training areas with a certain degree (a certain likelihood). The fact I
> am only using one band is driven by the fact that only band 4 of Landsat
> 7 reflectances shows significant difference in value in my training
> areas than the other unclassified areas. Using twice the same band (band
> 4) is fine, but I am having difficulties in grouping the same band.
> Using i.group for instance recognizes that the map is the same and does
> not add it twice to the group, therefore I cannot use i.maxlik.
> I don't know if producing textures is the way to go in my case, but I
> will give this a try before rejecting this option. First, however, I
> need to study this function output.
> Meanwhile, many thanks to both of you (Veronoca and Nikos)! If you have
> any other useful idea, I will consider them as well.

Moritz Lennert:

If you only work with one band, you could use your training areas to
define the mean value and standard deviation in band 4 that corresponds
to your class of interest and then just use r.recode to classify your
image with something like this:

mean-stddev:mean+stddev:1
*:0

Interesting. But that would depend a lot of how big the study extent
is, how many the training areas are, how they are spread, the illumination
geometry of the input acquisition, and more I guess.

Obviously you can play around with the stddev value and see if it should
be 1 stddev, 1/2 stddev, 2 stddev, etc, depending on your desired
confidence level. Obviously this all only holds if your distribution is
normal, but then again AFAIU that's the basic underpinning if maximum
likelihood.

However, even though you might not observe significant differences in
values between sites in individual bands, you might have significant
differences in the combination of bands. With that in mind, it still
might be worthwile to try your classification with several bands. At
least bands 2,3 and 5 might be interesting to add as they are used in
ice and snow indices...

I second that. You could also try some PCA to see if you can get
some enhanced "spectral profiles" (albeit the output range of values
will be something else than the input of course) for what you are looking for.
Just feed as many bands in i.pca and see for interesting principal components.

Nikos

On 14/10/15 17:40, Nikos Alexandris wrote:

Moritz Lennert:

If you only work with one band, you could use your training areas to
define the mean value and standard deviation in band 4 that corresponds
to your class of interest and then just use r.recode to classify your
image with something like this:

mean-stddev:mean+stddev:1
*:0

Interesting. But that would depend a lot of how big the study extent
is, how many the training areas are, how they are spread, the illumination
geometry of the input acquisition, and more I guess.

This problem is present whatever your technique. But technically, unless I'm completely mistaken, what I propose is a real maximum likelihood classification. i.maxlik could not do anything else with only one band.

Using just the info of one band to identify such features sounds quite hazardous to me, though. More auxiliary info would be better. Segmenting the image and then filling the polygon attribute table with other info (which could include infos derived from a DEM or other layers) might be the best way to go.

Moritz

Thanks again Moritz.
Of course I have other strategies to map permafrost, not only this, but I’d rather use them in a second phase. For instance, I have cumulative global radiation data during summer derived with r.sun function and summed up. I used these data to perform a parallel classification by setting an upper value of cumulative value to my rock glaciers (75th percentile in my dataset), and keep only thise pixels to be classified which fall below this threshold. then I will perform the band 4 (let’s call it “spectral classification”), AND I will overlap the two (and surely the info from the DEM), into a final classification according to certain criteria which I have in my mind.
@Nikos. Thanks again for the suggestion. I already tried the PCA but it gave me no interesting results in view of my classificaiton. I will try to fool the i.maxlik by creating a group with band 4 and a copy of it with modified name and see what will happen.
Again, many thanks to all the precious sugegstions, I didn’ expect such partecipation and I am considering all your precious hints!

Il 14/10/15 17:59, Moritz Lennert mlennert@club.worldonline.be ha scritto:

On 14/10/15 17:40, Nikos Alexandris wrote:

Moritz Lennert:

If you only work with one band, you could use your training areas to
define the mean value and standard deviation in band 4 that corresponds
to your class of interest and then just use r.recode to classify your
image with something like this:

mean-stddev:mean+stddev:1
*:0

Interesting. But that would depend a lot of how big the study extent
is, how many the training areas are, how they are spread, the illumination
geometry of the input acquisition, and more I guess.

This problem is present whatever your technique. But technically, unless I’m completely mistaken, what I propose is a real maximum likelihood classification. i.maxlik could not do anything else with only one band.

Using just the info of one band to identify such features sounds quite hazardous to me, though. More auxiliary info would be better. Segmenting the image and then filling the polygon attribute table with other info (which could include infos derived from a DEM or other layers) might be the best way to go.

Moritz