예제 #1
0
/** Returns reflected version of a matrix */
const math::matrix<float> Convolution::reflection(const math::matrix<float> A)
{
    int size = A.rowno();
    math::matrix<float> C(size, size);
    int col = A.colno();
    int row  = A.rowno();

    for (int x = 0; x < row; x++){
        for (int y = 0; y < col; y++){
            C((size - 1 - x), (size - 1 - y)) = A(x, y);
        }
    }
    return C;
}
예제 #2
0
/** Joins to matrices by multiplying the A[i,j] with B[i,j].
  * Warning! Both Matrices must be squares with the same size!
  */
const math::matrix<float> Convolution::join(math::matrix<float> A, math::matrix<float> B)
{
    int size = A.rowno();
    math::matrix<float> C(size, size);

    for(int x=0; x<size; x++){
            for(int y=0; y<size; y++) {
                C(x, y) = A(x, y) * B(x, y);
            }
        }
    return C;
}
예제 #3
0
/** Sums all of the matrixes elements */
const float Convolution::sum(const math::matrix<float> A)
{
    float sum = 0.0;
    int col = A.colno();
    int row  = A.rowno();
    for(int x=0; x<row; x++){
            for(int y=0; y<col; y++){
                sum += A(x,y);
            }
        }

    return sum;

}
예제 #4
0
const int MorphDilate::morph(math::matrix<float> window, math::matrix<bool> se)
{
    float min = PIXEL_VAL_MAX+1;
    int tempx,tempy;
    tempx = window.rowno();
    tempy = window.colno();
    for(int i=0;i<tempx;i++){
        for(int j=0;j<tempy;j++){
            if(se(i,j)==true){
                if(window(i,j)<min){
                    min = window(i,j);
                }
            }
        }
    }

    return (int) min;
}
예제 #5
0
const int MorphErode::morph(math::matrix<float> window, math::matrix<bool> se)
{
    float max=0.0;
    int row = se.rowno();
    int col = se.colno();

    for(int i=0; i<row; i++)
    {
        for(int j=0; j<col; j++)
        {
            if(se(i,j)==true && window(i,j)>max)
            {
                max = window(i,j);
            }
        }
    }

    return max;
}