jonathan-roos commited on
Commit
b95ca35
1 Parent(s): 9d579c5

changed when the input img is turned to greyscale

Browse files
Files changed (1) hide show
  1. detector.py +3 -3
detector.py CHANGED
@@ -11,7 +11,8 @@ def chop_img(img, step):
11
  # crop the image into step*rows and step*columns
12
  imgCrop = img[int(0 + height / step * i): int(height / step + height / step * i),
13
  int(0 + width / step * j): int(width / step + width / step * j)]
14
- imgResize = cv.resize(imgCrop, (640, 512)) # Resize image
 
15
  imgAug = augment(imgResize)
16
  allImgs.append((imgResize, imgAug))
17
  j += 1
@@ -20,8 +21,7 @@ def chop_img(img, step):
20
 
21
  def augment(img):
22
  kernel = np.ones((5, 5), np.uint8)
23
- imgGray = cv.cvtColor(img, cv.COLOR_BGR2GRAY) # convert to grayscale
24
- imgBlur = cv.GaussianBlur(imgGray, (5, 5), 0) # apply gaussian blur
25
  imgThresh = cv.adaptiveThreshold( # apply adaptive threshold
26
  imgBlur, 255, cv.ADAPTIVE_THRESH_GAUSSIAN_C, cv.THRESH_BINARY_INV, 7, 5)
27
  imgDilation = cv.dilate(imgThresh, kernel, iterations=1) # apply dilation to amplify threshold result
 
11
  # crop the image into step*rows and step*columns
12
  imgCrop = img[int(0 + height / step * i): int(height / step + height / step * i),
13
  int(0 + width / step * j): int(width / step + width / step * j)]
14
+ imgGray = cv.cvtColor(imgCrop, cv.COLOR_BGR2GRAY)
15
+ imgResize = cv.resize(imgGray, (640, 512)) # Resize image
16
  imgAug = augment(imgResize)
17
  allImgs.append((imgResize, imgAug))
18
  j += 1
 
21
 
22
  def augment(img):
23
  kernel = np.ones((5, 5), np.uint8)
24
+ imgBlur = cv.GaussianBlur(img, (5, 5), 0) # apply gaussian blur
 
25
  imgThresh = cv.adaptiveThreshold( # apply adaptive threshold
26
  imgBlur, 255, cv.ADAPTIVE_THRESH_GAUSSIAN_C, cv.THRESH_BINARY_INV, 7, 5)
27
  imgDilation = cv.dilate(imgThresh, kernel, iterations=1) # apply dilation to amplify threshold result