src/Old/image_frequencies.cpp
// This function extracts all the configurations of a given mask (msk) in a give image (img) and store the occourences (frequencies) in the rRules vector
This function extracts all the configurations of a given mask (msk) in a give image (img) and store the occourences (frequencies) in the rRules vector
This function extracts all the configurations of a given mask ( msk ) in a give image ( img ) and store the occourences ( frequencies ) in the rRules vector
void CalculateConfigurationsFrequencyOnImage(const cv::Mat1b& img, const mask &msk, rule_set &rs) {
    cv::Mat1b clone;
    copyMakeBorder(img, clone, msk.border_, msk.border_, msk.border_, msk.border_, cv::BORDER_CONSTANT, 0);
    const int h = clone.rows, w = clone.cols;
    for (int r = msk.border_; r < h - msk.border_; r += msk.increment_) {
        for (int c = msk.border_; c < w - msk.border_; c += msk.increment_) {
            cv::Mat1b read_pixels = clone(cv::Rect(cv::Point(c - msk.left_, r - msk.top_), cv::Point(c + 1 + msk.right_, r + 1 + msk.bottom_))).clone();
            bitwise_and(msk.mask_, read_pixels, read_pixels);
            size_t rule = msk.MaskToLinearMask(read_pixels);
            rs.rules[rule].frequency++;
            if (rs.rules[rule].frequency == std::numeric_limits<unsigned long long>::max()) {
                std::cout << "OVERFLOW freq\n";
            }
        }
    }
}
void CalculateConfigurationsFrequencyOnImage ( const cv :: Mat1b & img , const mask & msk , rule_set & rs ) { cv :: Mat1b clone ; copyMakeBorder ( img , clone , msk . border_ , msk . border_ , msk . border_ , msk . border_ , cv :: BORDER_CONSTANT , 0 ) ; const int h = clone . rows , w = clone . cols ; for ( int r = msk . border_ ; r < h - msk . border_ ; r += msk . increment_ ) { for ( int c = msk . border_ ; c < w - msk . border_ ; c += msk . increment_ ) { cv :: Mat1b read_pixels = clone ( cv :: Rect ( cv :: Point ( c - msk . left_ , r - msk . top_ ) , cv :: Point ( c + 1 + msk . right_ , r + 1 + msk . bottom_ ) ) ) . clone ( ) ; bitwise_and ( msk . mask_ , read_pixels , read_pixels ) ; size_t rule = msk . MaskToLinearMask ( read_pixels ) ; rs . rules [ rule ] . frequency ++ ; if ( rs . rules [ rule ] . frequency == std :: numeric_limits < unsigned long long > :: max ( ) ) { std :: cout << " \n " ; } } } }
This function extracts all the configurations of a given mask (msk) in a give image (img) and store the occourences (frequencies) in the rRules vector
This function extracts all the configurations of a given mask ( msk ) in a give image ( img ) and store the occourences ( frequencies ) in the rRules vector