Пример #1
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;

}
Пример #2
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;
}
Пример #3
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;
}
Пример #4
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;
}