이러한 선의 각도를 알고있는 매우 낮은 품질의 이미지에서 선을 찾는 가장 좋은 방법은 무엇입니까?

Julie96

나는 Houghlines 변환을 사용하여 두 개의 수평선을 찾으려고합니다. 보시다시피 사진이 매우 시끄 럽습니다! 현재 내 워크 플로는 다음과 같습니다.

  • 이미지 자르기

  • 흐리게

  • 노이즈를 줄입니다.

  • 그것을 열고 "수평 커널"(kernel_1 = np.ones((10,1), np.uint8)

  • 문지방

  • Houglines

결과가 예상만큼 좋지는 않습니다 ... 더 나은 전략이 있습니까? 나는 항상 수평선에 대해 serach (따라서 abs (theta)는 항상 0 또는 pi로 닫힙니다 )

여기 내 원시 이미지

임계 값 결과

크리스토프 랙 비츠

the issue is the noise and the faint signal. you can subdue the noise with averaging/integration, while maintaining the signal because it's replicated along a dimension (signal is a line).

your approach using a very wide but narrow kernel can be extended to simply integrating along the whole image.

  1. rotate the image so the suspected line is aligned with an axis (let's say horizontal)
  2. sum up all pixels of one scanline (horizontal line), np.sum(axis=1) or mean, either way mind the data type. working with floats is convenient.
  3. work with the 1-dimensional series of values.

this will not tell you how long the line is, only that it's there and potentially spanning the whole width.

edit: since my answer got a reaction, I'll elaborate as well:

나는 당신이 "회색"기준선을 얻기 위해 그것을 로우 패스 할 수 있다고 생각한다. 그리고 나서 빼기 ( "가우스의 차이"). 그것은 당신에게 좋은 신호를 줄 것입니다.

import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt
import scipy.ndimage

im = cv.imread("0gczo.png", cv.IMREAD_GRAYSCALE) / np.float32(255)
relief = im.mean(axis=1)
smoothed = scipy.ndimage.gaussian_filter(relief, sigma=2.0)
baseline = scipy.ndimage.gaussian_filter(relief, sigma=10.0)
difference = smoothed - baseline
std = np.std(difference)
level = 2
outliers = (difference <= std * -level)
plt.plot(difference)
plt.hlines([std * +level, std * -level], xmin=0, xmax=len(relief))
plt.plot(std * -level + outliers * std)
plt.show()
# where those peaks are:
edgemap = np.diff(outliers.astype(np.int8))
(edges,) = edgemap.nonzero()
print(edges)           # [392 398 421 427]
print(edgemap[edges])  # [ 1 -1  1 -1]

줄거리

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관