Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

is my concept of infomax wrong or right?

hi. sorry guys i would like to know if my concept of implementation ICA infomax is wrong or what because the result is blank image. here is my code https://ideone.com/cok4XL

is my concept of infomax wrong or right?

hi. sorry guys i would like to know if my concept of implementation ICA infomax is wrong or what because the result is blank image. here is my code https://ideone.com/cok4XL

/***

                            This is ICA infomax implementation 
                            equation :  X = AS  where X is the mixture matrix, A is mixing matrix, S is the source

                            SO ------> S = WX   where W is unmixing matrix. 
                            and since there no way that we can recover the excat source image but 
                            so we use Y instead of S where U ~= S 
                            which gives us  U = WX

                            W = learning rate (YU) W + W

                            where Y = -tanh(U/2)
                            YU = I + Y (U)t

***/
#include <iostream>
#include <math.h>
#include <opencv2/opencv.hpp>
 using namespace std;
 using namespace cv;

 const char* depthToStr(int depth) {
  switch(depth){
    case CV_8U: return "unsigned char";
    case CV_8S: return "char";
    case CV_16U: return "unsigned short";
    case CV_16S: return "short";
    case CV_32S: return "int";
    case CV_32F: return "float";
    case CV_64F: return "double";
  }
  return "invalid type!";
}

 void ICA(Mat &w, Mat x, Mat &s)
 {

    // get the size of the unmixing matrix
    int Weightrows = x.rows;
    int Weightcols = x.rows;

    // learning rate
    float lnrate = 0.95;

    // U = source (s)
    Mat u;

    // y ---> is super guassian 
    Mat y;

    // YU
    Mat yu;
    // creating I (indentity matrix)
    Mat I = Mat::eye (x.rows, x.rows, CV_64F);

    // number of iterates
    int iteratesNumber = 0;



    // creating the unmixing matrix and set it to random variables
     w.create(Weightrows, Weightrows, CV_64F);
     randu(w, Scalar(-1), Scalar(1));

     x.convertTo(x, CV_64F);
     u.convertTo(u, CV_64F);
     cout << depthToStr(x.depth()) << endl << depthToStr(u.depth()) << endl<<depthToStr(w.depth()) <<endl;
    for(int iter = 0; iter < 10; iter++)
    {
        u = w * x;


        // set the super guassian (nonlinear)

        Mat tanh1, tanh2, tanh;
        exp (u, tanh1);
        exp (-1 * u , tanh2);

        tanh  = (tanh1 - tanh2) / (tanh1 + tanh2);
        y = -1 * tanh;

        yu = I + y * u.t(); 

        w = 0.95  * yu * w + w;

    }

    s = w * x;

 }
 int main()
 {
    Mat Image, weight, result;

    Image = imread("/home/pixar/Desktop/rmi.jpeg",0);
    imshow(" s", Image);


    ICA(weight, Image, result);
        cout << result <<endl;
        imshow(" ", result);
        waitKey(0);
    return 0;
 }

is my concept of infomax wrong or right?

hi. sorry guys i would like to know if my concept of implementation ICA infomax is wrong or what because the result is blank image. here is my code https://ideone.com/cok4XL

/***

                            This is ICA infomax implementation 
                            equation :  X = AS  where X is the mixture matrix, A is mixing matrix, S is the source

                            SO ------> S = WX   where W is unmixing matrix. 
                            and since there no way that we can recover the excat source image but 
                            so we use Y instead of S where U ~= S 
                            which gives us  U = WX

                            W = learning rate (YU) W + W

                            where Y = -tanh(U/2)
                            YU = I + Y (U)t

***/
#include <iostream>
#include <math.h>
#include <opencv2/opencv.hpp>
 using namespace std;
 using namespace cv;

 const char* depthToStr(int depth) {
  switch(depth){
    case CV_8U: return "unsigned char";
    case CV_8S: return "char";
    case CV_16U: return "unsigned short";
    case CV_16S: return "short";
    case CV_32S: return "int";
    case CV_32F: return "float";
    case CV_64F: return "double";
  }
  return "invalid type!";
}

 void ICA(Mat &w, Mat x, Mat &s)
 {

    // get the size of the unmixing matrix
    int Weightrows = x.rows;
    int Weightcols = x.rows;

    // learning rate
    float lnrate = 0.95;

    // U = source (s)
    Mat u;

    // y ---> is super guassian 
    Mat y;

    // YU
    Mat yu;
    // creating I (indentity matrix)
    Mat I = Mat::eye (x.rows, x.rows, CV_64F);

    // number of iterates
    int iteratesNumber = 0;



    // creating the unmixing matrix and set it to random variables
     w.create(Weightrows, Weightrows, CV_64F);
     randu(w, Scalar(-1), Scalar(1));

     x.convertTo(x, CV_64F);
     u.convertTo(u, CV_64F);
     cout << depthToStr(x.depth()) << endl << depthToStr(u.depth()) << endl<<depthToStr(w.depth()) <<endl;
    for(int iter = 0; iter < 10; iter++)
    {
        u = w * x;


        // set the super guassian (nonlinear)

        Mat tanh1, tanh2, tanh;
        exp (u, tanh1);
        exp (-1 * u , tanh2);

        tanh  = (tanh1 - tanh2) / (tanh1 + tanh2);
        y = -1 * tanh;

        yu = I + y * u.t(); 

        w = 0.95  * yu * w + w;

    }

    s = w * x;

 }
 int main()
 {
    Mat Image, weight, result;

    Image = imread("/home/pixar/Desktop/rmi.jpeg",0);
    imshow(" s", Image);


    ICA(weight, Image, result);
        cout << result <<endl;
        imshow(" ", result);
        waitKey(0);
    return 0;
 }

is my concept of infomax wrong or right?

hi. sorry guys i would like to know if my concept of implementation ICA infomax is wrong or what because the result is blank image. here is my code https://ideone.com/cok4XLcode:

/***

                            This is ICA infomax implementation 
                            equation :  X = AS  where X is the mixture matrix, A is mixing matrix, S is the source

                            SO ------> S = WX   where W is unmixing matrix. 
                            and since there no way that we can recover the excat source image but 
                            so we use Y instead of S where U ~= S 
                            which gives us  U = WX

                            W = learning rate (YU) W + W

                            where Y = -tanh(U/2)
                            YU = I + Y (U)t

***/
#include <iostream>
#include <math.h>
#include <opencv2/opencv.hpp>
 using namespace std;
 using namespace cv;

 const char* depthToStr(int depth) {
  switch(depth){
    case CV_8U: return "unsigned char";
    case CV_8S: return "char";
    case CV_16U: return "unsigned short";
    case CV_16S: return "short";
    case CV_32S: return "int";
    case CV_32F: return "float";
    case CV_64F: return "double";
  }
  return "invalid type!";
}

 void ICA(Mat &w, Mat x, Mat &s)
 {

    // get the size of the unmixing matrix
    int Weightrows = x.rows;
    int Weightcols = x.rows;

    // learning rate
    float lnrate = 0.95;

    // U = source (s)
    Mat u;

    // y ---> is super guassian 
    Mat y;

    // YU
    Mat yu;
    // creating I (indentity matrix)
    Mat I = Mat::eye (x.rows, x.rows, CV_64F);

    // number of iterates
    int iteratesNumber = 0;



    // creating the unmixing matrix and set it to random variables
     w.create(Weightrows, Weightrows, CV_64F);
     randu(w, Scalar(-1), Scalar(1));

     x.convertTo(x, CV_64F);
     u.convertTo(u, CV_64F);
     cout << depthToStr(x.depth()) << endl << depthToStr(u.depth()) << endl<<depthToStr(w.depth()) <<endl;
    for(int iter = 0; iter < 10; iter++)
    {
        u = w * x;


        // set the super guassian (nonlinear)

        Mat tanh1, tanh2, tanh;
        exp (u, tanh1);
        exp (-1 * u , tanh2);

        tanh  = (tanh1 - tanh2) / (tanh1 + tanh2);
        y = -1 * tanh;

        yu = I + y * u.t(); 

        w = 0.95  * yu * w + w;

    }

    s = w * x;

 }
 int main()
 {
    Mat Image, weight, result;

    Image = imread("/home/pixar/Desktop/rmi.jpeg",0);
    imshow(" s", Image);


    ICA(weight, Image, result);
        cout << result <<endl;
        imshow(" ", result);
        waitKey(0);
    return 0;
 }

is my concept of infomax wrong or right?

hi. sorry guys i would like to know if my concept of implementation ICA infomax is wrong or what because the result is blank image. here is my code:

/***

                            This is ICA infomax implementation 
                            equation :  X = AS  where X is the mixture matrix, A is mixing matrix, S is the source

                            SO ------> S = WX   where W is unmixing matrix. 
                            and since there no way that we can recover the excat source image but 
                            so we use Y instead of S where U ~= S 
                            which gives us  U = WX

                            W = learning rate (YU) W + W

                            where Y = -tanh(U/2)
                            YU = I + Y (U)t

***/
#include <iostream>
#include <math.h>
#include <opencv2/opencv.hpp>
 using namespace std;
 using namespace cv;

 const char* depthToStr(int depth) {
  switch(depth){
    case CV_8U: return "unsigned char";
    case CV_8S: return "char";
    case CV_16U: return "unsigned short";
    case CV_16S: return "short";
    case CV_32S: return "int";
    case CV_32F: return "float";
    case CV_64F: return "double";
  }
  return "invalid type!";
}

 void ICA(Mat &w, Mat x, Mat &s)
 {

    // get the size of the unmixing matrix
    int Weightrows = x.rows;
    int Weightcols = x.rows;

    // learning rate
    float lnrate = 0.95;

    // U = source (s)
    Mat u;

    // y ---> is super guassian 
    Mat y;

    // YU
    Mat yu;
    // creating I (indentity matrix)
    Mat I = Mat::eye (x.rows, x.rows, CV_64F);

    // number of iterates
    int iteratesNumber = 0;



    // creating the unmixing matrix and set it to random variables
     w.create(Weightrows, Weightrows, CV_64F);
     randu(w, Scalar(-1), Scalar(1));

     x.convertTo(x, CV_64F);
     u.convertTo(u, CV_64F);
     cout << depthToStr(x.depth()) << endl << depthToStr(u.depth()) << endl<<depthToStr(w.depth()) <<endl;
    for(int iter = 0; iter < 10; iter++)
    {
        u = w * x;


        // set the super guassian (nonlinear)

        Mat tanh1, tanh2, tanh;
        exp (u, tanh1);
        exp (-1 * u , tanh2);

        tanh  = (tanh1 - tanh2) / (tanh1 + tanh2);
        y = -1 * tanh;

        yu = I + y * u.t(); 

        w = 0.95  * yu * w + w;

    }

    s = w * x;

 }
 int main()
 {
    Mat Image, weight, result;

    Image = imread("/home/pixar/Desktop/rmi.jpeg",0);
    imshow(" s", Image);


    ICA(weight, Image, result);
        cout << result <<endl;
        imshow(" ", result);
        waitKey(0);
    return 0;
 }

is my concept of infomax wrong or right?

hi. sorry guys i would like to know if my concept of implementation ICA infomax is wrong or what because the result is blank image. here is my code:

/***

                            This is ICA infomax implementation 
                            equation :  X = AS  where X is the mixture matrix, A is mixing matrix, S is the source

                            SO ------> S = WX   where W is unmixing matrix. 
                            and since there no way that we can recover the excat source image but 
                            so we use Y U instead of S where U ~= S 
                            which gives us  U = WX

                            W = learning rate (YU) W + W

                            where Y = -tanh(U/2)
                            YU = I + Y (U)t

***/
#include <iostream>
#include <math.h>
#include <opencv2/opencv.hpp>
 using namespace std;
 using namespace cv;

 const char* depthToStr(int depth) {
  switch(depth){
    case CV_8U: return "unsigned char";
    case CV_8S: return "char";
    case CV_16U: return "unsigned short";
    case CV_16S: return "short";
    case CV_32S: return "int";
    case CV_32F: return "float";
    case CV_64F: return "double";
  }
  return "invalid type!";
}

 void ICA(Mat &w, Mat x, Mat &s)
 {

    // get the size of the unmixing matrix
    int Weightrows = x.rows;
    int Weightcols = x.rows;

    // learning rate
    float lnrate = 0.95;

    // U = source (s)
    Mat u;

    // y ---> is super guassian 
    Mat y;

    // YU
    Mat yu;
    // creating I (indentity matrix)
    Mat I = Mat::eye (x.rows, x.rows, CV_64F);

    // number of iterates
    int iteratesNumber = 0;



    // creating the unmixing matrix and set it to random variables
     w.create(Weightrows, Weightrows, CV_64F);
     randu(w, Scalar(-1), Scalar(1));

     x.convertTo(x, CV_64F);
     u.convertTo(u, CV_64F);
     cout << depthToStr(x.depth()) << endl << depthToStr(u.depth()) << endl<<depthToStr(w.depth()) <<endl;
    for(int iter = 0; iter < 10; iter++)
    {
        u = w * x;


        // set the super guassian (nonlinear)

        Mat tanh1, tanh2, tanh;
        exp (u, tanh1);
        exp (-1 * u , tanh2);

        tanh  = (tanh1 - tanh2) / (tanh1 + tanh2);
        y = -1 * tanh;

        yu = I + y * u.t(); 

        w = 0.95  * yu * w + w;

    }

    s = w * x;

 }
 int main()
 {
    Mat Image, weight, result;

    Image = imread("/home/pixar/Desktop/rmi.jpeg",0);
    imshow(" s", Image);


    ICA(weight, Image, result);
        cout << result <<endl;
        imshow(" ", result);
        waitKey(0);
    return 0;
 }