Reputation: 165
I followed (and modified) the method from the best-rated answer of this post.
My image is a little bit different. I used HoughLinesP and managed to detect the majority of red lines.
I was wondering is there a way to remove detected lines from the image, without damage to the other black intersecting lines? I am interested in black lines only. Is there a smarter way to isolate black lines without too many missing pixels and segments?
Upvotes: 3
Views: 1616
Reputation: 46600
If you want to isolate just black lines, a simple Otsu's threshold and bitwise-and should do it
import cv2
image = cv2.imread('3.jpg')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
thresh = cv2.threshold(gray, 0, 255,cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1]
result = cv2.bitwise_and(image,image,mask=thresh)
result[thresh==0] = (255,255,255)
cv2.imshow('thresh', thresh)
cv2.imshow('result', result)
cv2.waitKey()
Upvotes: 2
Reputation: 7353
This looks like a problem of signal-separation/processing.
I don't know if this would work or not. But this is just a hunch. Give it a shot and see if it works. Assume your image as a convolved image of the measuring strip and the ECG. So, if you process this in the Fourier domain, perhaps you could dis-entangle these two types of signals.
scipy
has fft
functionality). Call the original image: f
and fft-image: F
. g
, fft-image: G
. In case this does not work, please leave a note in the comment section.
Upvotes: 0