0

I am trying to detect two vertical lines shown in the attached images using some image processing methods. The line are in low contrast.

The location is shown in the first image with yellow arrows. The original image is also attached.

I tried using adaptiveThresholding and normal thresholding using maximum and minimum at local windows. But I can't detect the lines.

Any ideas how to detect the two vertical lines in image processing?

enter image description here

enter image description here

1
  • Have you tried looking at the line profile through the object (perpendicular to the lines you want)? Might be that you can find something in the 1d profile if you do derivative filtering like gradient or Laplace Commented Oct 2, 2017 at 9:42

1 Answer 1

1

There is some trick when contrast is low in bright pixels. There is thresholding method - otsu thresholding (https://en.wikipedia.org/wiki/Otsu%27s_method), which can be used to detect bright side of histogram. After that, you can normalize that part of histogram to (0,255) and set 0 to darker pixels as in code below:

cv::Mat img = cv::imread("E:\\Workspace\\KS\\excercise\\sjB8q.jpg", 0);
cv::Mat work;
for (int i = 0; i < 4; i++) // number of iterations has to be adjusted
{
    cv::threshold(img, work, 30, 255, CV_THRESH_OTSU);
    cv::bitwise_and(img, work,img);
    cv::normalize(img, img, 0, 255, cv::NORM_MINMAX, -1, work);
}

Then your contrast will be better like in pictures below (for different iterations):

i=2:

enter image description here

i=4:

enter image description here

i =6:

enter image description here

After that preprocessing detecting dark lines should be easier. That answer is just explanation of idea. If you want to know more just ask in comment.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.