Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Separating relatively dark slabs from non-uniform background

Hello,

Actually i asked this in an onether entry. But i think it's a new subject. I apologize in advance if it's double entry

https://forums.ni.com/t5/Machine-Vision/Marble-slab/td-p/3708856/page/4

 

I have marble slabs. With line scanning get i image of these marble slabs. In result image background is extremely dark. But background is not completely dark (it's no-uniform). If you look carefully, you can see some parts on background that not total black are (contrast enhanced image_01) . Most marble slabs have some dark areas, too.

I want to find contour of these marble slabs. To do that first i need to separate marble from this background. I use manual thresholding (thresholding bright objects, see attached script). I can't find an auto thresholding methode for this. Manual thresholding doesn't always work for me. Sometimes i have to change lower value for manual thresholding. I don't want this.

 

Is there a better way to that? I think i might use some gray morphology before thresholding. Any ideas?

 

 

0 Kudos
Message 1 of 4
(2,371 Views)

I see what you mean with the two example images.

 

How about color thresholding + some IMAQ FillHoles? Does the attached script work consistently for you?

0 Kudos
Message 2 of 4
(2,337 Views)

We have always different marbles. Size and color are changing. There are dark marbles but bright marbles, too.

scanned_20171227_225721.jpgscanned_20171229_174530.jpg 

Some marbles natural holes on them. We want to detect these holes, too So, i rather don't want use "fill holes"
Marble slab with holesMarble slab with holes

0 Kudos
Message 3 of 4
(2,333 Views)

That's actually quite a more interesting problem than I thought 🙂

 

Now there are two paths I would try (I don't really know how much your images vary..)

 

1) Build a threshold that first distinguishes between background and marble slab (cracks considered foreground/marble) including FillHOles..
I would personally use local statistics for it, seems like the background is very dark, has low minimum values and low std deviation.
Mask the background (make it totally black), then use a second mask.. 
(IMAQ BlockStatistics is your friend)

 

2) H-Dome Binary reconstruction thresholds. That algorithm is a bit a long story to explain.. ,in essence, it reconstructs local maxima/minima.

Has two parameters: The delta which is recognized as a relevant and the area in which it looks.

I attached an example that works with the pics you attached.

 

 

 

Message 4 of 4
(2,322 Views)