JADAK VIDEO: Clarity Machine Vision Software – The Count Plug-In

This video demonstrates JADAK’s Clarity Machine Vision Software Count Plugin. Find out why JADAK machine vision is used by more medical device companies and OEMs than any other vision provider.

*Want to learn more about JADAK’s Medical Machine Vision Platforms and Services?  Register for a Tech Consultation Day from the experts at JADAK! Also, be sure to visit our RFID Products and Services,  Barcode and Machine Vision pages.


Below is the video transcript.

Clarity 2.0 Machine Vision Software

Count – Setting Up and Running the Scripts


This video is going to go over the Count widget. So the Count widget uses different methods to count different clusters of pixels. You can adjust all of these different settings down here [at bottom below image] to count all the clusters that you desire. We call them “Blobs” within Clarity. So I started off to click the Count Widget icon [at top of screen]. Right now I have a bunch of canned images from previous jobs. Right here is a picture we had made with a set background value and a bunch of different squares.

I’m going back to the Blob Count. What we want to do first is adjust our region of interest, which is this red square here. You click and drag, from these red circles over here, to get the area you desire. We have three different types of Blob Counting. First you count the actual blobs. You can count the Boundary of the blobs, so if you zoom in here you can see some different color highlighted edges up there. And another option we have is the boundary matching, and you can train the program to look for a certain reference boundary.

We’ll start off focusing on this bottom area of the Light Blobs. So within Clarity you can choose to either look for dark blobs or light blobs. We’re going to switch over to light blobs. We want to go back to blob counting. And as you can see, all 12 of these squares in our region of interest have been counted.

Now let’s say we only want to count the medium sized box. So how we do that is adjust our maximum area and our minimum area. That is strictly just the number of pixels in each cluster. Our max area, we just need to reduce to get rid of the large ones, and that seems to be good enough. The minimum area, we need to increase to get rid of the smaller areas. Now we have just the middle boxes and as you can see [in Step List Blob Count on left] the blog count is 4.

Another thing I’d like to point out is that this started out as red [Step List box on left] and then turned to green and that’s because of this Pass Criteria section over here [bottom below image]. So if you have a required number of items that you need to count, and you need them to be less than 10, which is what we have here, this will fail unless it’s within that range. You can adjust this so if you only want 4 blobs, you can have a minimum of 4 and a maximum of 4, and if you have anything outside of that it will turn back to red.

Another thing we want to touch on is to work on this threshold area. The threshold area just talks about the brightness of the pixels. Right now it says the Threshold is 160. If you hover over any area in your image and look down in this section over here, it will give you the RGB values of that pixel. So the background is 125, this white area is 255 which is the brightest you can get, and then the black box is all zeros. So let’s try Fixed Option and we only want to count anything that is exactly white. All we have to do is increase our threshold all the way to the top. Only the white blobs are counted for. And you can do that in reverse as well. Let’s go back to Adaptive here, the black boxes go and nothing lit up because our blob polarity is still set up to look for the light clusters instead of the dark clusters. The threshold here is set to 40. The background of this is 125. This slightly dark gray is 40 so it’s not counted, and the dark blob is 0. So we can go to fixed and if we lower our threshold, everything’s counted. As you can see only the medium boxes are selected because our max and min area are still the same as before.

Let’s try another way to count using the Boundary Counting. Let’s switch back to Light Blobs, and we’re going to go back to Adaptive, which is an auto threshold. Let’s do Boundary Counting. So in Boundary Counting what you can do is the program will look for a closed boundary and then will count that as a blob. This whole box is outlined in light blue, so it’s counting that whole bounded area as a blob. These smaller blobs are not counted, but that’s because our minimum length is set to 100, so let’s just lower that to 5. They’re all there. The ROI is highlighted red again because the max number is 10 and right now it’s counting 12.

Let’s do another thing where we do Boundary Matching. Let’s train in on some of these huge ones. It gets highlighted in blue that way you know it’s an acceptable boundary. We’re going to accept that and scroll out a little bit and adjust our region of interest. We’re getting these 8 blobs here. And I just changed it to 8 so it was a pass. The Closed Boundary length is 397. Let’s say you only wanted the boxes that were the big boxes, you can adjust your minimum length to be just under the 397 and it will nix out those other ones. It matches what you need.

Let’s go back to Blob Counting. What we’re going to do is show you the Allow Boundary option. Let’s get this max area back up and the min area down. Right now the program is only counting blobs completely enclosed in the region of interest. Let’s say we want any blob that can be in the area, so we click Allow Boundary Blobs, and what happens is the program recognizes any cluster of blob that doesn’t have a full boundary on it within the ROI.

Let’s do some more realistic blobbing, rather than these beautiful perfect squares. Let’s go to Picture #1 which is some M&MS and some chocolate wafers. We have to adjust our region of interest so this section is the only section we’re interested in. They’re counting 18 blobs right now and that’s just these cluster of pixels because our minimum area is set to 5. So let’s do for this first blob count function, let’s only count the larger wafers. We’re still set to only look for the light blobs and we want the dark blobs because they’re darker than the background. Let’s up this minimum area and we don’t want any of these smaller areas, we only want specifically this size wafer. And in our pass criteria let’s say we want at least 4 wafers, and we’re going to put our maximum to 15, because there’s no such thing as too many chocolate wafers. That one looks good. I want to edit it so I know what it means, and this is going to be “number of wafers.”

So let’s do another count function or Count widget. Back to a new blob count, we have to adjust this region of interest again. This one we’re only going to count M&Ms, same automatic threshold as before. We need to up this maximum area to include all of that and we want to increase the minimum area so it’s just under the size of our M&Ms and the max area just over the size. This upper M&M isn’t being counted because it’s on the border. So let’s adjust this a little bit. We were getting this dark edge we don’t want. So know we have 1, 2, 3, 4, 5 M&Ms. Let’s adjust this name so it’s “number of M&Ms.”

We’re going to do one more, which is going to count all chocolates. Once again we’ll have to adjust the region of interest. We’re going to do the max area to include the wafers and the minimum area to include just under the M&Ms. 4 wafers, 5 M&Ms, 9 total chocolates.

Let’s do a quick output here. We’re going to add text. First thing we’re going to look at is the number of wafers. Within this drop down we’ll do the Blob Count, which will output the number of blobs it literally counted. We’re going to do another text output, space first, Number of M&Ms. Within same thing, blob count. Output. Add another text “is there enough chocolates?” which is the main question. So number of chocolates, and right here we’re going to do the result. Let me adjust a quick thing, so it actually makes sense. Let’s say the reason we’re doing this is we want to make sure we have enough chocolates. So the maximum number of blobs is 100 and the minimum number of blobs at least 9. We just want to make sure everything else matches this. Max number is 10, max number is 15, minimum of 4. In our output result you can see the number of wafers is 4, number of M&Ms is 5. Is there enough chocolates? Yes there is.

So let’s run the next image that we have. This also passes because we have 5 wafers, and as you can see allow boundaries is on so this wafer is also counted, and we have 7 M&Ms. That is more than the 9 chocolates, so passed.

As you can see here, 9 M&Ms, but no wafers, so there is enough chocolate. This is still highlighted in red.

As you can see, this one we have a false. So we have 5 wafers, which pass. But no M&Ms, so not enough chocolates. So it fails.


News & Resources

JADAK’s “Reagent Authentication with RFID” – Webinar Recording

In today’s rapidly changing medical testing environment, laboratory processes are

October 17, 2017

EMS Inventory Management using RFID

From gaining up to 40% efficiency to cutting costs by

October 13, 2017

NFC HF in In-Vitro Diagnostic (IVD) Device

This case study details how JADAK’s Near Field Communication (NFC) High

September 14, 2017