I have some image like this:

There is a gap in some lines, How can I detect gap’s position in image?
It’s the result. It seems closing creates new pixels.

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
May i assume that the final goal is close the gap?
Than you might want to use morphological operations. To close the gap you just need the so called “closing“. This is done by applying “dilation” and than an “erosion“.
So how do you find a position where the gap was closed? You can just compare the before and after image and look at the changes.
EDIT: after your post i decided to update the answear. So i tried a little piece of code in matlab.
it produces an resulting image:
So basicly we have found the right position, but have unfortunatly got alot of false positives. I think you can get the result you want by treating each one of them as a candidate match and getting rid of the false positives. One important part of the false positives seems to be that if you check their vertical neighborhood (in the original image) you will find that there are white pixels, because the white line was not really disconnected there (and they therefore can not be the right solution). So you can try to use that to discard the false positives.