onilink_

Untitled

Feb 8th, 2019
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. std::vector<unsigned> hei_line(COLS);
  2.     std::vector<unsigned> hei_prev(COLS);
  3.     std::vector<unsigned> col_y(COLS);
  4.    
  5.     for(unsigned l=0; l<LINES; ++l) {
  6.         // calcul de h_l
  7.         for(unsigned c=0; c<COLS; ++c) {
  8.             if(im({c,l}) == od::Color::White) {
  9.                 hei_line[c] = 0;
  10.             } else {
  11.                 if(l > 0) {
  12.                     hei_line[c] = hei_prev[c]+1;
  13.                 }
  14.                 else {
  15.                     hei_line[c] = 1;
  16.                 }
  17.             }
  18.         }
  19.         hei_prev = hei_line;
  20.         // Enumération de tous les bords gauche et droit
  21.         for(unsigned c1=0; c1<COLS; ++c1) {
  22.             unsigned h = 0xFFFFFFFF;
  23.             for(unsigned c2=c1; c2<COLS; ++c2) {
  24.                 h = std::min(h, hei_line[c2]);
  25.                
  26.                 unsigned wid = c2 - c1 + 1;
  27.                 unsigned hei = h;
  28.                 unsigned area = wid * hei;
  29.                
  30.                 if(max.area < area) {
  31.                     max.pos.x = c1;
  32.                     max.pos.y = l - hei + 1;
  33.                     max.size.wid = wid;
  34.                     max.size.hei = hei;
  35.                     max.area = area;
  36.                 }
  37.             }
  38.         }
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment