1aff9ce62a0c9db7f02b93830fed4073fed49bd1,functions/LinearSpectralUnmixing.py,LinearSpectralUnmixing,updatePixels,#LinearSpectralUnmixing#Any#Any#Any#,57

Before Change



        //// TO DO: this only works for 1 pixel at a time, specified by [row][col]
        //// assuming that inBlockT has correctly accessed a numpy ndarray
        pixel = inBlockT[0][0]
        // solve simultaneous equations with numpy linear algebra least squares
        results = np.linalg.lstsq(signaturesT, pixel)

        //// TO DO:

After Change


        // [B, G, R, NIR1, SWIR1, SWIR2] at each pixel
        inBlockT = inBlock.transpose([1, 2, 0])
        // reshape to slightly flatten to 2d array
        inBlockTFlat = inBlockT.reshape((-1, inBlockT.shape[-1]))

        // solve simultaneous functions at each pixel stack
        // looping and output of new array of all lstsq results
        def unmixPixel(pixelStack, sigs):
            solution = np.linalg.lstsq(sigs, pixelStack)
            results = np.append(solution[0], solution[1][0]) // return endmembers and residual
            return results

        // np.apply_along_axis seems to be slower than native Python looping
        outBlock = np.apply_along_axis(unmixPixel, 1, inBlockTFlat, signaturesT)

        // outBlock shape is (n, 4); must reconstruct into endmember bands with values in correct x,y
        // e.g. you can reconstruct:  inBlockTFlat.reshape((1994,2310,6)) back to inBlockT
        // here we need (1994,2310,4) without residuals; (1994,2310,5) with residuals
        outBlockReshaped = outBlock.reshape(-1, inBlock.shape[-1], 5).transpose((2,0,1))

        pixelBlocks["output_pixels"] = outBlockReshaped.astype(props["pixelType"])
        return pixelBlocks
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: Esri/raster-functions
Commit Name: 1aff9ce62a0c9db7f02b93830fed4073fed49bd1
Time: 2015-02-02
Author: jwasilkowski@esri.com
File Name: functions/LinearSpectralUnmixing.py
Class Name: LinearSpectralUnmixing
Method Name: updatePixels


Project Name: pgmpy/pgmpy
Commit Name: f58745ab284f48b7ef4ce813f5f8cd26bdb3c0a8
Time: 2015-06-16
Author: ankurankan@gmail.com
File Name: pgmpy/inference/Sampling.py
Class Name: BayesianModelSampling
Method Name: forward_sample


Project Name: rasbt/mlxtend
Commit Name: f4a5be4f4a404c30c9acaac2c2e691021d4715b0
Time: 2015-12-10
Author: mail@sebastianraschka.com
File Name: mlxtend/preprocessing/mean_centering.py
Class Name: MeanCenterer
Method Name: transform