LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mango Texture Defect Detection

Solved!
Go to solution

Hi NI community,

I'm working on a project to detect texture defects on mangoes, such as brown stains, black stains, and bruises/scratches. I'm using Vision Assistant for image processing, but I'm still figuring things out.

I've been trying to explore color processing functions in Vision Assistant, but I'm finding it a bit confusing. Should I be working with RGB images, grayscale conversions, or doing particle analysis on binary images? I've attached some mango images from my samples for context. These images feature mangoes with various texture defects. A defect-free mango would simply exhibit a nice green color with no stains or scratches.

Any advice or guidance would be greatly appreciated!

Thanks in advance.

0 Kudos
Message 1 of 8
(686 Views)

You need to search for basic image processing . 

In your case, one way is to extract a B&W image then you need a threshold to cleary identify the black marks you need to detect, 

then you need to play around with the functions to determine your criteria: like size of the dots, number of dots found etc. 

 

 

0 Kudos
Message 2 of 8
(661 Views)

@ccp1999 wrote:

Should I be working with RGB images, grayscale conversions, or doing particle analysis on binary images?


You'll almost certainly get better results if you convert to HSL (or HSV).

 

Black has low L, greens have a range of H, greys have a low S. A multi threshold on H, S and L would allow you to pick out greens, backs and\or greys.

 

You'll never succeed with R, G, B. It's very unintuitive, because for instance white has a higher G value than green.

0 Kudos
Message 3 of 8
(628 Views)
Solution
Accepted by topic author ccp1999

If at all possible, fix the lightning. Good lightning is 90% of a good vision application.

 

If you can get rid of the cast shadow and shading (the sides of the DUT), both black as a defect, things will become a lot easier.

 

So, light the DUT from all sides.

 

EDIT: maybe you're trying to do that, it could be the color of the mangos. Still, there's a shadow on the left.

 

IMG_20210415_152204

 

You could also make the object stand out even more with a red or blue (any not white\black\green) background, and\or a semi transparent background lit from behind.

 

The white of the background probably reduces the exposure of the camera, and this compresses the intensity range of the greens. A grey background (or and background with the same or lower L as the object) might do wonders.

0 Kudos
Message 4 of 8
(623 Views)

Thank you for the advice! I adjusted the settings on brightness, contrast, and gamma, which helped me get rid of most of the shadow.

post.png

I also experimented with the HSL and HSV color spaces to highlight the defects I want to detect. It turns out that these settings gave me the best results, well, acceptable for me, even though I initially found the optimal threshold values by chance.

Message 5 of 8
(524 Views)

That's a good looking mango!

0 Kudos
Message 6 of 8
(518 Views)

What a cool project! You should take a look at various color channels independently to see if the brown spots show up with more contrast in one channel vs anther. Then you can use that channel to do thresholding to convert the image into a binary (Black and white) image, where the spots are in black. This will allow you to then determine their count, size, and area, which are likely going to be related to your pass/fail criteria. Love it!

_____________
Creator of the BundleMagic plugin for LabVIEW!
0 Kudos
Message 7 of 8
(500 Views)

@littlesphaeroid wrote:

What a cool project! You should take a look at various color channels independently to see if the brown spots show up with more contrast in one channel vs anther. Then you can use that channel to do thresholding to convert the image into a binary (Black and white) image, where the spots are in black. This will allow you to then determine their count, size, and area, which are likely going to be related to your pass/fail criteria. Love it!


In HSL space, brown will have an H that's different from green.

 

That's why HSL is great when you work with color. It get's 'shady' when the colors get darker, but with bright colors, you only need one H range to select a color.

 

RGB is really tricky, not to the computer, but to us.

 

For instance, most human would say A has (is?) more green than B:

 

wiebeCARYA_1-1717747217026.png

 

Yet, the B (pink) has 3.5 times more green than A (green)!

 

The hue solves this problem entirely.

 

The only tricky thing about hue is that reds go through 0. So from 0 to 15 AND from 210 to 240 (in LV's ranges, sometimes H is 0-1 or 0-255, not sure what IMAQ uses). But since we're dealing with greens here, that's not a problem.

 

In IMAQ, I'd use the multi threshold VI on the HSL\HSV, where the S and L\V ranges will probably be very large, only eliminating the purest whites and blacks.

0 Kudos
Message 8 of 8
(484 Views)