개정판 9ff9a98d
issue #000: standardize image opening
Change-Id: Ic7167761945271dd6042931f73ab57f389e74212
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
369 | 369 |
|
370 | 370 |
if self._imgSrc is None and self._imgFilePath is not None and os.path.isfile(self._imgFilePath): |
371 | 371 |
self._imgSrc = cv2.cvtColor(AppDocData.my_imread(self._imgFilePath), cv2.COLOR_BGR2GRAY) |
372 |
self._imgSrc = cv2.threshold(self._imgSrc, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1] |
|
373 |
''' |
|
372 | 374 |
kernel = np.array([[-1, -1, -1], |
373 | 375 |
[-1, 9, -1], |
374 | 376 |
[-1, -1, -1]]) |
... | ... | |
377 | 379 |
# smooth = cv2.addWeighted(blur, 1.5, self._imgSrc, -0.5, 0) |
378 | 380 |
# self._imgSrc = cv2.threshold(smooth, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)[1] |
379 | 381 |
self._imgSrc = cv2.threshold(self._imgSrc, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1] |
382 |
''' |
|
380 | 383 |
|
381 | 384 |
configs = AppDocData.instance().getConfigs('Filter', 'DilateSize') |
382 | 385 |
if 1 == len(configs) and int(configs[0].value) is not 0: |
... | ... | |
384 | 387 |
kernel = np.ones((size, size), np.uint8) |
385 | 388 |
self._imgSrc = cv2.erode(self._imgSrc, kernel, iterations=1) |
386 | 389 |
|
390 |
configs = AppDocData.instance().getConfigs('Filter', 'FlatSize') |
|
391 |
if 1 == len(configs) and int(configs[0].value) is not 0: |
|
392 |
size = int(configs[0].value) |
|
393 |
kernel = np.ones((size, size), np.uint8) |
|
394 |
self._imgSrc = cv2.morphologyEx(self._imgSrc, cv2.MORPH_CLOSE, kernel) |
|
395 |
self._imgSrc = cv2.morphologyEx(self._imgSrc, cv2.MORPH_OPEN, kernel) |
|
396 |
|
|
387 | 397 |
return self._imgSrc |
388 | 398 |
|
389 | 399 |
''' |
내보내기 Unified diff