1
우리는 논리 회로의 적절한 그림을 그린 스캔 이미지로 시작했는데 논리 회로를 스캔 한 이미지와 논리 회로를 분리 할 수 있었지만 더 이상 진행할 방법이 없었고이를 위해 python open cv를 사용했습니다. 상기 우리 코드손으로 그려진 회로의 스캔 이미지에서 로직 게이트를 감지하는 방법은 무엇입니까?
import cv2
import numpy as np
from matplotlib import pyplot as plt
img = cv2.imread('logic.png',0)
ret,img2 = cv2.threshold(img,127,255,cv2.THRESH_BINARY_INV) # converting the image into binary image.
kernel = cv2.getStructuringElement(cv2.MORPH_RECT,(100,3)) # kernel to detect vertical lines
vertical = cv2.morphologyEx(img2, cv2.MORPH_OPEN, kernel) # applying morphological opening operation to detect vertical lines
vertical = cv2.dilate(vertical,kernel,iterations = 1) #dilate the vertical lines obtained
kernel2 = cv2.getStructuringElement(cv2.MORPH_RECT,(3,100)) # kernel to detect horizontal lines
horizontal = cv2.morphologyEx(img2, cv2.MORPH_OPEN, kernel2) # applying morphological opening operation to detect horizontal lines
horizontal = cv2.dilate(horizontal,kernel2,iterations = 1) #dilate the horizontal lines obtained
cv2.imshow('d',vertical) # show the vertical imag
cv2.imshow('b',horizontal) # show the horizontal image
img = img2 -horizontal - vertical # subtracting horizontal and vertical lines from original image
cv2.imwrite('horizontal.png',horizontal)
cv2.imwrite('vertical.png',vertical)
cv2.imwrite('result.png',img)
cv2.imshow('last',img) # show the resulted image after subtraction
kerne = np.ones((3,3),np.uint8) # kernel to remove the noise from the last image
opening = cv2.morphologyEx(img, cv2.MORPH_OPEN, kerne) # applying opening morphological operation to remove the noise from the image
cv2.imshow('opening',opening) # show the resulted image after removing noise
cv2.imwrite('noise_removal.png',opening)
cv2.waitKey(0)
확인 결과 다음과 손으로 그려진 회로의 스캔 이미지에서 논리 게이트들을 검출하도록 더 진행하는 방법을 조언인가?
코드의 결과는 아래와 같다 :
1) 입력 이미지 :
2) 출력 영상 (코드 결과) :
결과 이미지가 링크 –
에 보이지 않습니다. 게이트 유형 만 감지하여 배열에 넣거나 이미지 분석을 통해 그래프 (트리)를 만들고 싶습니까? –
@Anatoly 결과 이미지 링크가 수정되었습니다. 먼저 게이트를 감지하고 회로의 표현을 분석하려고합니다. –