Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Is is possible to transform the resulting shape of a color threshold (vission assistant) into the largest possible (full) circle?

Hi!

 

I am using the Vision Builder for a machine vision application (color sorter). Once the object is under the frame, I am using the vision assistant to clear out backgound noise and extract information on only the object itself. The problem is that the background is (at times) very similar in color value to the object itself, making for a complicated separation of foreground and background. If I change the threshold values to remove the background entirely, I miss lighter colored objects altogether, so that is unfortunately not an option. By and in large, the objects are +- circular in nature, but vary slightly in size, so I was wondering, is it possible to morph the post color threshold image into the largest possible circle (an agressive version of open object maybe?)? I realize that I may lose some of the edges on the object itself, but that is better than incorporating non foreground information into my calculations. Ultimately, I am extracting color values and total area (px) of the detected object. Please see attached pic for illustration. Any help or suggesstions would be much appreciated.

Thank you!

 

0 Kudos
Message 1 of 10
(4,848 Views)

Hi

Its possible try convex hull function in morphology palatte.

---
Silver_Shaper | CLD
0 Kudos
Message 2 of 10
(4,840 Views)

Thank you Sasi. The next step in the sequence is actually convex hull. The problem is that as the resulting image of the color threshold is not really circular, convex hull essentially enlarges the object by connecting the pixels at the extremities of the identified part. Anyway, sorry for not being clearer as to what I am trying to achieve, my intention was that the "new" circle would be within the recognized pixels (so smaller), not overlapping (larger). I have reattached a new image to better illustrate. If this is not possible, any other suggesstions to obtain a more accurate reading of the shape of the object would be equally appreciated! As of now, I can munipulate the threshold values for light OR dark objects, but not both unfortunately as any efforts to do so recognize the background as part of the object 😞

 

Thanks again!

Jonathan

0 Kudos
Message 3 of 10
(4,835 Views)

Hi jbelga,

 

At first, you can do what you are trying to do, not much of difficult. Post your original image so that can help you much better.

---
Silver_Shaper | CLD
0 Kudos
Message 4 of 10
(4,827 Views)

Sure. I have attached a few images as follows:

 

wheel.jpg: this is simply an image of what the inspection area looks like, so as to better understand what the background is. It actually functions as a conveyor wheel and multiple inspection areas in one unit.

black.jpg: As far as I can tell, optimal RGB values for this color are R: 7-60, G: 7-160, B: 0-255. Anything above R=60 begins to incorporate background information

yellow.jpg: optimal RGB values for this color are R: 7-95, G: 7-160, B: 0-255. Anything below R=95 misses the stone

---following attachments in next post---

white.jpg: optimal RGB values for this color are R: 7-160, G: 7-160, B: 0-255. Anything below R=160 misses the stone

empty1: optimal RGB values for this color are R: 7-150, G: 7-160, B: 0-255. Anything above R=150 begins to incorporate background information

empty2.jpg: optimal RGB values for this color are R: 7-120, G: 7-160, B: 0-255. Anything above R=120 begins to incorporate background information

 

There are many more colors (infinite really), but these three examples are a pretty good indication of the problem. As you can see, the issue is with determining the right value for "Red" in RGB detection mode (I have also tried to switch to HSI,HSV, and HSL, but same problem). When it is high (above 60), it incorporates too much background information, but when it is low (under 160), it misses the light colored stones. I just can't seem to find the right compromise.

 

Thank you again for looking at this, I really apreciate it.

 

Best,

Jonathan

 

Download All
0 Kudos
Message 5 of 10
(4,816 Views)

more attachments...

Download All
0 Kudos
Message 6 of 10
(4,815 Views)

I played around with your images, and it looks like thresholding based on saturation seems to work well. I attached the Vision Assistant script I used. It's not polished, but it should give you some ideas to play around with.

 

The saturation plane in a compressed jpg is always going to be kind of blocky and noisy, so I expect it will work even better with uncompressed images. Still, the results on the jpgs you posted seem decent. I included the Danielsson Morphology step at the end just to give you a better idea of how the Circle Detection step works (since Circle Detection uses Danielsson internally, see the Vision Concepts Manual for more details).

 

KevinC

0 Kudos
Message 7 of 10
(4,776 Views)

Thanks Kevin. Unfortunately, I was not able to open your attachment. I am running a full featured 2010 version of Vision Builder, but see no options to save or open .vascr files. Also, Labview is not installed. Not sure if that is the problem.

 

If you reckon I don't have the proper config to read the file (lack of developer license perhaps?), could you please send me some screen shots so I could rebuild the script and test it?

 

Thanks again.

 

Jonathan

0 Kudos
Message 8 of 10
(4,772 Views)

Color Plane Extraction 1: HSL - Saturation Plane

Threshold 1: Auto Threshold: Clustering

Adv. Morphology 1: Remove small objects

Adv. Morphology 2: Fill Holes

Circle Detection 1

 

 

Hope that helps,

KevinC

0 Kudos
Message 9 of 10
(4,762 Views)

Wow! Your suggestion is infinitely better at recognizing the stones than the original sequence I was using. Thank you!. However, it seems to be problematic when there is no stone in the inspection area (i.e empty1.jpg and empty2.jpg). I'm curious, what do you see when you process the empty images on your end, does it come up empty? Because with me it is basically recognizing the entire screen. I tried manual thresholding, but again, this is could for some scenerios but not others 😞

 

Also, when there is more than one stone in the inspection area (different colors), the automatic threshold works for one, but not the other (see multistone2.jpg).  Ultimately, I just want to get a as accurate as possible a reading of the shape under detection (regardless of color or quantity), so as to extract area (indication if I am looking at more than 1 stone), and if only one, color.

 

Is my approach to this entirely off, or do you think I just need to refine these steps (which I have been unsuccessful with so far)?

 

P.S I was not able to use the circle detection (no developer license), but after further testing with your suggested sequence, I think "forcing" a circle on the shape would not be ideal, especially in the case of multiple stones.

 

Thanks again for your help!

 

Jonathan

0 Kudos
Message 10 of 10
(4,721 Views)