Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::vector<unsigned> hei_line(COLS);
- std::vector<unsigned> hei_prev(COLS);
- std::vector<unsigned> col_y(COLS);
- for(unsigned l=0; l<LINES; ++l) {
- // calcul de h_l
- for(unsigned c=0; c<COLS; ++c) {
- if(im({c,l}) == od::Color::White) {
- hei_line[c] = 0;
- } else {
- if(l > 0) {
- hei_line[c] = hei_prev[c]+1;
- }
- else {
- hei_line[c] = 1;
- }
- }
- }
- hei_prev = hei_line;
- // Enumération de tous les bords gauche et droit
- for(unsigned c1=0; c1<COLS; ++c1) {
- unsigned h = 0xFFFFFFFF;
- for(unsigned c2=c1; c2<COLS; ++c2) {
- h = std::min(h, hei_line[c2]);
- unsigned wid = c2 - c1 + 1;
- unsigned hei = h;
- unsigned area = wid * hei;
- if(max.area < area) {
- max.pos.x = c1;
- max.pos.y = l - hei + 1;
- max.size.wid = wid;
- max.size.hei = hei;
- max.area = area;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment