Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

Editing Snippet ID: #1006555
Snippet name:
Category, Type:
Content:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
static float autoCropOfBWImage_blackBG_threshold = 0.2f;
static Rect autoCropOfBWImage_blackBG(BWImage img) {
  ret autoCropOfBWImage(img, new Rect(0, 0, img.getWidth(), img
.getHeight()));
}
static Rect autoCropOfBWImage_blackBG(BWImage img, Rect r) {
  ret autoCropOfBWImage(img, r, autoCropOfBWImage_blackBG_threshold
);
}
// r = initial rectangle
static Rect autoCropOfBWImage_blackBG(BWImage img, Rect r, float 
threshold) {
  int x1 = r.x, y1 = r.y, x2 = r.x2(), y2 = r.y2();
  // left side
  end1:
  while (x1 < x2) {
    for (int y = y1; y < y2; y++)
      if (img.getPixel(x1, y) >= threshold)
        break end1;
    x1++;
  }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Comment:
Public (visible to everyone):
Created: 2017-01-16 12:31:56

This page without fancy editor.