Discussion:
[otb-users] a PCA transformation issue, the Dimensionality Reduction module
Kimi
2018-08-22 13:47:54 UTC
Permalink
Hi all,

I would like to do the pca (principal component analysis) of my Sentinel-2
multiband image composed of nine 20m-L2A rasters. I tried with the
otbcli_DimensionalityReduction module (the method parameter was set to
“pca”), but the statistics of the output image is not as I expected.
Namely, all the bands of the output image has the standard deviation equal
to 1.

Generally, I expected that the output pca bands have standard deviations
different from 1. This would then allow me to select the most significant
bands according to the variance loss criteria.

Is this a bug of the DimensionalityReduction –pca algorithm, or there is
maybe another way in orfeo toolbox to get the pca bands without std
normalized to 1?

Thank you in advance for your time and the help!

Cheers,
Kimi


PS.
otbcli_DimensionalityReduction -in test2.tif -out pca_norOFF.tif -method
pca -normalize 0
otbcli_ComputeImagesStatistics -il pca_norOFF.tif
and this is the statistics for 9 bands from the pca output image:

Mean: 2.14067, -1.29191, 0.554654, 0.996805, -0.267422, 0.423317, 0.285117,
0.281447, -0.183358 Standard Deviation: [1, 1, 1, 1, 1, 1, 1, 1, 1]

My input multiband image can be downloaded from here:

https://files.fm/u/2vh7aqvu
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html

You received this message because you are subscribed to the Google
Groups "otb-users" group.
To post to this group, send email to otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Kimi
2018-08-30 07:34:10 UTC
Permalink
Hi all,

Did I maybe posed a question that is outside the interest of the otb-users?

I would really appreciate help/clarification regarding the pca issue
reported in the previous post.

Thanks in advance!

Kimi
Post by Kimi
Hi all,
I would like to do the pca (principal component analysis) of my Sentinel-2
multiband image composed of nine 20m-L2A rasters. I tried with the
otbcli_DimensionalityReduction module (the method parameter was set to
“pca”), but the statistics of the output image is not as I expected.
Namely, all the bands of the output image has the standard deviation equal
to 1.
Generally, I expected that the output pca bands have standard deviations
different from 1. This would then allow me to select the most significant
bands according to the variance loss criteria.
Is this a bug of the DimensionalityReduction –pca algorithm, or there is
maybe another way in orfeo toolbox to get the pca bands without std
normalized to 1?
Thank you in advance for your time and the help!
Cheers,
Kimi
PS.
otbcli_DimensionalityReduction -in test2.tif -out pca_norOFF.tif -method
pca -normalize 0
otbcli_ComputeImagesStatistics -il pca_norOFF.tif
Mean: 2.14067, -1.29191, 0.554654, 0.996805, -0.267422, 0.423317,
0.285117, 0.281447, -0.183358 Standard Deviation: [1, 1, 1, 1, 1, 1, 1, 1,
1]
https://files.fm/u/2vh7aqvu
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html

You received this message because you are subscribed to the Google
Groups "otb-users" group.
To post to this group, send email to otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jordi Inglada
2018-09-03 09:46:36 UTC
Permalink
Hi Kimi,

The components are given as directions (eigenvectors) and are therefore
normalized (unit vectors). You can use the eigenvalues (the variance of
each direction) to select the components[1]. They are stored in a file
which has the same name as the model but with a .txt extension.

Best wishes,

Jordi

[1] https://en.wikipedia.org/wiki/Principal_component_analysis#Intuition
Post by Kimi
Hi all,
I would like to do the pca (principal component analysis) of my Sentinel-2 multiband image composed of nine 20m-L2A rasters. I tried with the otbcli_DimensionalityReduction module (the method parameter was set to “pca”), but the statistics of the output image is not as I expected.
Namely, all the bands of the output image has the standard deviation equal to 1.
Generally, I expected that the output pca bands have standard deviations different from 1. This would then allow me to select the most significant bands according to the variance loss criteria.
Is this a bug of the DimensionalityReduction –pca algorithm, or there is maybe another way in orfeo toolbox to get the pca bands without std normalized to 1?
Thank you in advance for your time and the help!
Cheers,
Kimi
PS.
otbcli_DimensionalityReduction -in test2.tif -out pca_norOFF.tif -method pca -normalize 0
otbcli_ComputeImagesStatistics -il pca_norOFF.tif
Mean: 2.14067, -1.29191, 0.554654, 0.996805, -0.267422, 0.423317, 0.285117, 0.281447, -0.183358 Standard Deviation: [1, 1, 1, 1, 1, 1, 1, 1, 1]
https://files.fm/u/2vh7aqvu
--
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html

You received this message because you are subscribed to the Google
Groups "otb-users" group.
To post to this group, send email to otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Kimi
2018-09-03 12:45:37 UTC
Permalink
Hi Jordi,

Thank you for your answer and the wiki link! I read carefully the wiki
section, and this is all fine, but I do not know how to interpret the
output image of the “otbcli_DimensionalityReduction”.


Is the output image the pca-transformed input image? If yes, why is the
standard deviation of each band in the output image equal to 1?


You also mentioned the following “You can use the eigenvalues 
 They are
stored in a file
which has the same name as the model but with a .txt extension. ”.


Maybe I am missing something here, but in “otbcli_DimensionalityReduction”
there is no “model” parameter. The only txt file I can get is a 9x9 matrix
resulting from the option “-outmatrix”. However, in the otb help, it is
explained shortly that this is a “transformation matrix”.


Does the “-outmatrix” option provide a matrix with the eigenvectors?


Thank you for your time and help!

Cheers,

Kimi
Post by Jordi Inglada
Hi Kimi,
The components are given as directions (eigenvectors) and are therefore
normalized (unit vectors). You can use the eigenvalues (the variance of
each direction) to select the components[1]. They are stored in a file
which has the same name as the model but with a .txt extension.
Best wishes,
Jordi
[1] https://en.wikipedia.org/wiki/Principal_component_analysis#Intuition
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html

You received this message because you are subscribed to the Google
Groups "otb-users" group.
To post to this group, send email to otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jordi Inglada
2018-09-03 14:26:10 UTC
Permalink
Post by Kimi
Hi Jordi,
Thank you for your answer and the wiki link! I read carefully the wiki section, and this is all fine, but I do not know how to interpret the output image of the “otbcli_DimensionalityReduction”.
Is the output image the pca-transformed input image? If yes, why is the standard deviation of each band in the output image equal to 1?
The outputs are the components. They have unit variance, and if you wan to reconstruct the original data, you have to multiply each component by the square root of the correspondign eigenvalue.
Post by Kimi
You also mentioned the following “You can use the eigenvalues … They are stored in a file
which has the same name as the model but with a .txt extension. ”.
Maybe I am missing something here, but in “otbcli_DimensionalityReduction” there is no “model” parameter. The only txt file I can get is a 9x9 matrix resulting from the option “-outmatrix”. However, in the otb help, it is explained shortly that this is a “transformation matrix”.
Does the “-outmatrix” option provide a matrix with the eigenvectors?
Sorry. I thought you were using the new dimensionality reduction applications (TrainDimensionalityReduction and ImageDimensionalityReduction). The former has a -io.out parameter to store the reduction model.

In the case of the application you are using, I guess that the transformation matrix must contain non unit eigenvectors from which you can derive the eigenvalues (but I am only guessing, you should check).
Post by Kimi
Thank you for your time and help!
Cheers,
Kimi
Hi Kimi,
The components are given as directions (eigenvectors) and are therefore
normalized (unit vectors). You can use the eigenvalues (the variance of
each direction) to select the components[1]. They are stored in a file
which has the same name as the model but with a .txt extension.
Best wishes,
Jordi
[1] https://en.wikipedia.org/wiki/Principal_component_analysis#Intuition
--
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html

You received this message because you are subscribed to the Google
Groups "otb-users" group.
To post to this group, send email to otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...