 # Dimensionality Reduction: How to apply inverse transform?

I do not understand how to apply the inverse transform with OTB. As far as I understand, after the direct transform
`otbcli_DimensionalityReduction -in CupriteAVIRISSubset.dat -out outpca.tif -outmatrix outmat.csv`
then do something to outpca.tif and apply the inverse. I should be able to input a modified pca-transformed image, the covariance eigenvector matrix and the nb of components, and a name for the output image.
Agus

The inverse is calculated during the process directly. You have to specify the inverse output using the argument -outinv

see the help for otbcli_DimensionalityReduction

``````   otbcli_DimensionalityReduction -help
``````

Here is an example:

``````otbcli_DimensionalityReduction -in F:\temp\QB_1_ortho.tif^
-out F:\temp\outpca.tif^
-outinv F:\temp\outinv.tif^
-outmatrix F:\temp\outmat.csv
``````

In my case the result did not look much different, as there were only 4 MS-bands but for your HSI-dataset ist should be more interesting. Good luck!

This does not make any sense, does it? If you apply the inverse transform
as a part of the direct transform process you will always get the same as the input: by definition,
the inverse of the transform is the original image.
The point is doing something in the transform space and then apply the inverse to get back to the original space. A simple case is the decorrelation stretching (which is not what I’m about doing).
Agus

You are right - I just realized that, too, after inspecting the values. Identical…let´s see what the OTB team has to say Hello,

Indeed, the inverse is computed during the process. This can be useful to perform PCA based denoising by reprojecting only the components corresponding to the first eigenvalues.

This being said, it would be interesting to be able to provide the transformation and/or the transformed image.

Cédric

In my opinion, this is a waste of effort, as you restrict the application of inverse PCA to just denoising by
keeping some of the components for the inverse. Even in that case, note that you must do a first run to inspect the
PCA image and its eigenvalues to really decide how many components you want to keep for the inverse PCA. So there is no real advantage on keeping both modes together and it is very counter-intuitive.
I suggest modifying the procedure by introducing a parameter to indicate inverse mode and, in that case, require a -inmatrix to input the eigenvector matrix (previously calculated as -outmatrix in the direct run). This would be more general and would let the user apply the inverse PCA for other purposes than denoising.