Пример #1
0
void writeMagnitude(cimg_library::CImg<T>& image, const std::vector<T>& magnitude) {
    for (int x=0; x<image.width(); x++) {
        for (int y=0; y<image.height(); y++) {
            const unsigned char mag = magnitude[y*image.width()+x];
            const unsigned char color_mag[] = { mag, mag, mag };
            image.draw_point(x, y, color_mag);
        }
    }
}
Пример #2
0
void writeMagnitudeDirection(cimg_library::CImg<T>& image, const std::vector<T>& magnitude, const std::vector<float>& direction) {
    for (int x=0; x<image.width(); x++) {
        for (int y=0; y<image.height(); y++) {
            float _r,_g,_b;
            HSVtoRGB(&_r, &_g, &_b, direction[y*image.width()+x]*180/M_PI, 1, (float)magnitude[y*image.width()+x]/255.0);
            const T color_dir[] = { (int)floor(_r*255), (int)floor(_g*255), (int)floor(_b*255) };
            image.draw_point(x, y, color_dir);
        }
    }
}
Пример #3
0
void flood(cimg_library::CImg<unsigned char> &draw_image, std::vector<std::vector<int> > &energy_map, char *color, int val, int x, int y) {
    if (!valid_coord(std::pair<int, int>(x, y), energy_map[0].size(), energy_map.size())) return;
    if (energy_map[x][y] == val) return;

    draw_image.draw_point(y, x, color);
    energy_map[x][y] = val;

    flood(draw_image, energy_map, color, val, x - 1, y); 
    flood(draw_image, energy_map, color, val, x + 1, y); 
    flood(draw_image, energy_map, color, val, x, y - 1); 
    flood(draw_image, energy_map, color, val, x, y + 1); 
}
Пример #4
0
void applyQWAF(cimg_library::CImg<T>& image,cimg_library::CImg<T>& out) {
    for (int x=0; x<image.width(); x++) {
        for (int y=0; y<image.height(); y++) {
            Quaternion q[9];
            for (int ix=-1; ix<=1; ix++) {
                for (int iy=-1; iy<=1; iy++) {
                    int mx=x,my=y;
                    coord(mx, my, image.width(), image.height());
                    q[(iy+1)*3+(ix+1)] = Quaternion(0,image(mx,my,0,0),image(mx,my,0,1),image(mx,my,0,2));
                }
            }

            //Get the weighted average filter
            Quaternion p = QWAF(q);
            int mx=x, my=y;
            coord(mx, my, image.width(), image.height());
            T col[3] = { (T)p.b, (T)p.c, (T)p.d };
            out.draw_point(mx, my, col);
        }
    }
}