Mert Mert - 1 month ago 12
C++ Question

Finding Line Spacings in Thresholded Image - R/C++ Image Processing

Hello Stackoverflowers,

I have a question about Image Processing. I will give a short introduction about my project, clear things up and ask my question.


I use R now, with EBImage library. After that I will write that code on C++.


In material analysis, the microstructural analysis are done in sake of understanding the structure of steel. It gives some hints to the analyzer.

My duty is; finding the line spacings in the image. I will explain it by images.


Image is taken from: https://de.wikipedia.org/wiki/Perlit_(Stahl)


I will post a collage image, because I cannot upload images more than 2.
First photo is the image of perlit microstructure. Second photo is thresholded image after preprocessing. Third photo is what I made on Paint to show you the regions that I need to find.


  1. Photo, "Pre-processing" is done by doing:


    • Grayscaling the Image.

    • Closing Filter by 7x7 Gaussian Kernel

    • Dilating Filter by 3x3 Box Kernel

    • Median Filter 7x7

    • Thresholding Image




Black and White image in collage photo is the result of these steps.

Collage Photo of Perlit

Now, if you look this image, there are some line spacings shown by red pencil via Paint, in the 3rd photo. I want to make a segmentation to show them painted.

You can clearly see that I got rid of tiny vertical lines, made clear segments.

I need help in segmentation. I am currently reading lots of computer vision and image processing books, but unfortunately I couldn't find a good solution. In EBImage, there are some functions but "bwlabel" or "watershed" didn't help me a lot.


The segmentation will be done in this image horizontally. But there would be an image with gradiental line spacings.


I am not asking this question for ready copy-paste answers. I really want to learn how to do this. Any help will be highly appreciated.

Thank you very much for reading my questions.

Answer

There seems to be a horizontal pattern in the structure.. is it always like this? Have you tried exploiting this correlation? Maybe extract vertical histogram (histogram over rows of pixels), and find maximas?

I reread your question, already saw that you are taking into account the horizontality. Knowing this, if you just want to paint the red regions, then you already have a good binary mask to paint them.. or you dont want to paint the small white patches between the dark structure?

Cheers