© Distribution of this video is restricted by its owner
01:24 | Okay. Uh Do you have any ? Any questions with respect of the |
|
|
01:39 | ? I believe it's due tonight. go on. Yeah. No you |
|
|
01:59 | have to push any of your They're automatically generated at the back |
|
|
02:11 | Yeah. So do not. Hard uh you know size of the image |
|
|
02:17 | the column? It which you're splitting of that has to be taken from |
|
|
02:20 | input arguments. Any more questions. one. Okay. Uh let's get |
|
|
03:08 | then. Um So we've been talking binary images if you remember the last |
|
|
03:14 | . Um you know we introduced what binary images and we said we'll ask |
|
|
03:19 | same two questions as we asked in beginning. That is how do you |
|
|
03:23 | information in the form of a binary ? The second question was how do |
|
|
03:27 | improve the information in a in an in this case in a binary |
|
|
03:32 | So in the last class we did how I can get how I can |
|
|
03:36 | a binary image. Um That is how I can capture information the form |
|
|
03:40 | a binary image. And today we'll with the second question and try to |
|
|
03:45 | how we can improve the information in binary image. Okay, once I |
|
|
03:49 | a binary image um how do I it. Right so going back again |
|
|
03:54 | said binary images or those that take value of either zero or one at |
|
|
03:59 | pixel location, thereby valued and in they tend to represent some feature and |
|
|
04:05 | image and we said we'll follow the that one. Well um one is |
|
|
04:13 | by black and zero is represented by . Okay. And um how do |
|
|
04:20 | get? How do we create binary ? How did we create binary images |
|
|
04:27 | where do we get binary images from ? We can get it from grayscale |
|
|
04:35 | . That is correct. One is there are devices that create binary images |
|
|
04:39 | ? Like caresses to pad Or we actually take a grayscale image and then |
|
|
04:45 | a binary image from that. So how do we create a binary |
|
|
04:48 | from a grayscale image? What is basic operation to do that? We |
|
|
04:54 | to do thresh holding right that is define a threshold and then you compare |
|
|
04:59 | pixel with that threshold. If it's than threshold you give it a |
|
|
05:03 | If it's greater than threshold you give up one, you get a by |
|
|
05:06 | , the major at that point. okay. And we said um the |
|
|
05:16 | itself will depend on the image. ? Not all thresholds will work for |
|
|
05:20 | images but every image you would have define a particular threshold or you have |
|
|
05:26 | estimate a threshold? Right now, did we go about doing it in |
|
|
05:31 | ? Um What kind of images can can we actually threshold to create the |
|
|
05:39 | images? Do they have to have certain character with respect to the hissed |
|
|
05:46 | gram? The instagram has to be model that is. When you look |
|
|
05:57 | the instagram there should be at least peaks between which you can establish a |
|
|
06:03 | . Right. If you do that we can find a threshold between them |
|
|
06:06 | we can use that to create a image. Right, okay, now |
|
|
06:12 | saw two ways to estimate this Uh do you guys remember what those |
|
|
06:26 | the 11 of them was arses thresh ? Right. How do we do |
|
|
06:30 | is thresh holding, what is the idea for artist thresh holding? |
|
|
06:50 | You take the hissed a gram and how do we do about the stress |
|
|
07:03 | ? What is the overall idea? ? That is funny. That was |
|
|
07:12 | first method we saw. Right. The first method was an iterative method |
|
|
07:19 | we said, okay, I do know the where the peaks are |
|
|
07:22 | If I knew the peaks, I find the threshold by averaging them |
|
|
07:26 | Um but at the same time to the peaks, I need to know |
|
|
07:29 | the threshold is. Right. So was kind of, we had to |
|
|
07:33 | with an iterative problem where we made assumption on the threshold, given the |
|
|
07:37 | , we took expectations on either side gave us the locations of the |
|
|
07:42 | And given those peaks, we computed threshold again and we kept doing that |
|
|
07:46 | the expectations did not move anymore. . This was a simple iterative algorithm |
|
|
07:51 | we saw to solve it right. the second method was the arts is |
|
|
07:56 | holding. So how did we do holding please? Mhm. The idea |
|
|
08:13 | that for every possible threshold it will the history Graham into two parts. |
|
|
08:19 | that will give you two statistical Right? And you want to compare |
|
|
08:23 | statistical values to decide which one is better threshold. Right. In our |
|
|
08:28 | we said a good a good metric compare is the weighted sum of intra |
|
|
08:33 | variances. Right? And we can that for every possible threshold and essentially |
|
|
08:39 | the one that gives you the least sum of inter class variances. And |
|
|
08:43 | be a threshold. Right. And also saw an example for that With |
|
|
08:50 | little six x 6 image that can six different intensity levels. And for |
|
|
08:56 | possible intensity level we computed the Okay, okay. So now given |
|
|
09:04 | image, you can use any of methods to create a grayscale image. |
|
|
09:07 | now you have, I'm sorry to a binary image. So now we |
|
|
09:11 | a binary image and we'll do things kind of improve that binary image. |
|
|
09:19 | . All right. So let's talk little more about history grams because it |
|
|
09:24 | keep coming up as we go through . Um One is that we already |
|
|
09:28 | in order to do thresh holding or create a binary image. Our image |
|
|
09:33 | to a grayscale image needs to have bimodal hissed a gram. Right. |
|
|
09:37 | we think of examples of things that use every day that may end up |
|
|
09:41 | by model hissed a grams or images we take or look at in |
|
|
10:00 | when there is a large contrast between background and the foreground, you end |
|
|
10:04 | having a bi modal hissed a Right? There are a large number |
|
|
10:07 | pixels that have one certain pixel value another set of pixels which are the |
|
|
10:13 | . That may have a different set pixel values. Right? So if |
|
|
10:16 | take an example like uh like a printed media, right? Usually you |
|
|
10:21 | black text on white pages right now background is white and the foreground is |
|
|
10:27 | . And if you look at the graham for something like that, it |
|
|
10:31 | like a bi modal hissed a Right. Another example is um uh |
|
|
10:37 | cells in a solution, right? it's an example we already talked about |
|
|
10:42 | um we'll also actually do an assignment off of it. But in general |
|
|
10:46 | solution has a lighter color compared to blood cells. And when you look |
|
|
10:51 | the history graham for something like it has a by model hissed a |
|
|
10:54 | . You can do thresh holding you know, separate the background in |
|
|
10:58 | foreground, reduce the cells in the . Okay. Um and more |
|
|
11:03 | you know sometimes your image may not end up having a bi modal hissed |
|
|
11:07 | gram. In which case you can an environment that will produce a bi |
|
|
11:11 | hissed a gram. Right? For , uh if you go to a |
|
|
11:15 | store and scan things right. One the things is you know, there's |
|
|
11:18 | little scanner and you can scan it in general it's an illuminated surface, |
|
|
11:22 | ? It looks like there's a light that, right? That's because when |
|
|
11:24 | put your object on top it's dark that light both combined will produce two |
|
|
11:30 | pixel values for the background and what scanning. Right? That's the |
|
|
11:33 | You get a bi modal instagram and you want to threshold it you can |
|
|
11:36 | that. Okay, Okay. Um again, like I said, you |
|
|
11:47 | , bimodal instagrams are good but you , often times you your image may |
|
|
11:52 | up having multiple modes, right? you may not be able to control |
|
|
11:56 | environment but you would still have to a grayscale image, a binary image |
|
|
12:00 | that application. So in these what happens is that certain number of |
|
|
12:04 | pixels may end up being foreground pixels the other way. Right, so |
|
|
12:09 | of the foreground pixels may end up classified as the background pixels. Now |
|
|
12:14 | these cases you would have to do sort of region correction or you would |
|
|
12:18 | to do additional operations to improve the in the image. Okay. And |
|
|
12:23 | look at how we can do that two different ways. Yeah. So |
|
|
12:34 | mean um so basically a lot of operations will allow us will actually look |
|
|
12:40 | will be doing logical operations. So we've talked about this and we |
|
|
12:45 | oh since it's by valued image it take only zeros and ones you can |
|
|
12:49 | look at them as true or false . If you look at them as |
|
|
12:52 | or false values, you can actually up applying logical operations on them. |
|
|
12:57 | . What are the logical operations that are common? You need at least |
|
|
13:04 | . Right and orange knock. Yeah, those are the ones we'll |
|
|
13:08 | and in addition we look at one operation. So what is an end |
|
|
13:15 | to input variables? What will be response from an and gate B for |
|
|
13:24 | to produce a one? Both the have to be one. Right. |
|
|
13:27 | all the inputs are one, you get a one that's an end. |
|
|
13:31 | , what's in order? That's Or all the inputs have to be |
|
|
13:40 | to produce zero, otherwise they'll produce one. Right? And then you |
|
|
13:43 | a simple compliment as well? A becomes a one and one becomes a |
|
|
13:48 | . Right. And of course there these uh these laws that we've also |
|
|
13:56 | . Does anyone remember these laws? are their? What is Law two |
|
|
14:06 | 3 associative four and five. Sorry mutated fine. Well what about |
|
|
14:23 | 7 distributed in the last two or morgans was perfect. Okay, |
|
|
14:35 | So apart from this uh so the basic ones are and or and not |
|
|
14:39 | apart from that will use the fourth which is called majority. Okay, |
|
|
14:43 | the first rule for majority is that number of inputs have to be |
|
|
14:47 | Okay, so you cannot apply it inputs, you cannot apply it on |
|
|
14:51 | inputs, but you can apply it the number of inputs is three or |
|
|
14:56 | or seven or so forth. And it's it's the majority because it |
|
|
15:00 | what it says right? The result basically equal to the majority of the |
|
|
15:05 | that are in there. Right? if you look at the truth table |
|
|
15:08 | this with three inputs, you will that whenever there are two ones you |
|
|
15:13 | a one or when there are two you get a zero or when there |
|
|
15:17 | three ones, you gotta one. ? So basically whichever one is the |
|
|
15:21 | value of the inputs, that's the you get. Okay, now this |
|
|
15:26 | one more additional operation, logical operation we'll use. Okay, is |
|
|
15:31 | Okay. Alright, now how do apply these on images? Right now |
|
|
15:38 | restrict ourselves to these four operations. is not an orange majority. Um |
|
|
15:45 | we'll try to apply them on Now, when I say applying logical |
|
|
15:49 | on image images, there are two to do it. One is that |
|
|
15:53 | can take two images right to binary and I can apply logical operation between |
|
|
16:01 | pixels in those two images to get output image. Right? That's one |
|
|
16:06 | to do it. In other ways I can take only one image and |
|
|
16:10 | can define a small region in that I can take all the binary values |
|
|
16:15 | there and apply a logical operation on values. Okay. That's the second |
|
|
16:20 | to do it. And we'll look doing both both those ways and we'll |
|
|
16:24 | why they're helpful in certain scenarios. right. So let's look at some |
|
|
16:34 | of applying the uh, the logical . Uh the most straightforward operation is |
|
|
16:41 | a north operation and for the north you only need one input image. |
|
|
16:45 | what it does is basically every pixel complemented. If it's a zero, |
|
|
16:48 | becomes a one. If it's a it becomes a zero. Okay. |
|
|
16:52 | on the other hand, I can take two images and I can apply |
|
|
16:56 | and operation on them. Okay, is the first time I was talking |
|
|
17:00 | you take two images and apply the between corresponding pixels in the image. |
|
|
17:05 | is I 100 and I 200. ? The row and the column same |
|
|
17:13 | both the pixels. Right? I that for all the pixels that are |
|
|
17:15 | the in both the images and I a result. Now, if I |
|
|
17:19 | to apply an and what I end getting is the overlap of black |
|
|
17:24 | Right? So if you remember we one is represented by black and zero |
|
|
17:29 | represented by white. Right? So I take image I one and I |
|
|
17:33 | here and if I apply an and between them, that's the result I |
|
|
17:38 | and it is the overlap of the regions. Now I can also apply |
|
|
17:43 | or operation between them. Now, I do that, what do I |
|
|
17:46 | up getting please? That's right. I get the overlap of white |
|
|
17:59 | Right, so it is an example do that. Okay, perfect. |
|
|
18:07 | let's look at an application where this be useful. This is the setup |
|
|
18:12 | have. Okay, now again, remind ourselves, I said I can |
|
|
18:16 | logical operations on on images in two . One is that I can apply |
|
|
18:20 | on two separate images, right? corresponding pixels. The second one is |
|
|
18:25 | can take one image and define a region and apply on the on that |
|
|
18:29 | region. Okay, so we're looking the first kind now where you have |
|
|
18:33 | images and trying to apply a logical between them. Okay, so here |
|
|
18:40 | an example where applying such operation can useful. So this is the setup |
|
|
18:45 | have. It's it's an industrial environment I have a conveyor belt on which |
|
|
18:50 | producing some a manufacturing something in this that bolt and what I want to |
|
|
18:56 | is have a setup where I can each bolt to decide if it's defective |
|
|
19:02 | not. Okay, so I have conveyor belt, I have the bolts |
|
|
19:07 | are manufactured are coming on it and have a mechanism to take images of |
|
|
19:12 | one of these boats as they Okay, now, apart from |
|
|
19:16 | what I also have is a reference or a model image. Now, |
|
|
19:20 | does images saying? Oh, perfectly bolt should look like this. |
|
|
19:25 | it's a model of what I should now, as I keep coming and |
|
|
19:30 | course, uh, since I can the environment, I will control it |
|
|
19:33 | lights to make sure I get a image and I can threshold it to |
|
|
19:38 | a binary image. Okay, so a result I have two binary |
|
|
19:42 | One is for the model which says is a perfect bolt and one is |
|
|
19:48 | binary image that I keep capturing as bolt comes on. Okay, |
|
|
19:52 | what I want to do is I to compare the image I capture with |
|
|
19:56 | model image and see how much they . Right, larger the deviation implies |
|
|
20:02 | amount of defect and I can do quality control with that. Okay, |
|
|
20:08 | this is the images I get. , so the one we see on |
|
|
20:13 | left is I model right, that the reference image I have and the |
|
|
20:18 | I see on the right is the that I captured. Okay, and |
|
|
20:22 | for this example, let's say that little bolt has shifted to the right |
|
|
20:28 | certain amount. Okay, now, order to identify how much it has |
|
|
20:33 | , I have to identify both the in the black pixels and the white |
|
|
20:39 | . Right? So how do I that? So if if a certain |
|
|
20:48 | value is zero in both, that's . If it's one in both, |
|
|
20:53 | fine. But if it's zero in and one in the other one, |
|
|
20:57 | need to identify those or the other if it is one in the model |
|
|
21:01 | if it's zero in the one I , I need to identify those right |
|
|
21:06 | . How do I do this using logical operations? We just saw and |
|
|
21:11 | not. Majority eggs are great. , that's the correct answer. But |
|
|
21:23 | restricting ourselves to and or and not of course we can create almost any |
|
|
21:28 | using and or not now, how I create X are using and or |
|
|
21:33 | not. All right. Oh, said not or X or Yeah, |
|
|
21:52 | north and or will give you a . That's fine. That doesn't give |
|
|
21:56 | an X. All right. We the solution is X or write an |
|
|
22:00 | produces a one. Uh when well produces zero if both inputs are zero |
|
|
22:06 | one and producer one? Uh if of those is one. Right? |
|
|
22:17 | again, that's right. Mhm. what combination of applying logical operations on |
|
|
22:28 | two majors will give me that So maybe we can break it into |
|
|
23:07 | parts, Maybe I first I can only deviations in the black part and |
|
|
23:13 | can implement something else to find deviation the white part and then maybe I |
|
|
23:18 | combine those two right now, if pick one, how do I know |
|
|
23:23 | there is a deviation in the black ? Mhm mm an orbiting them and |
|
|
23:46 | necessarily. Mm uh so the way can do this is that you would |
|
|
23:57 | by taking the uh okay, so way you would do this is that |
|
|
24:08 | would take the so this is two to it, right, you would |
|
|
24:11 | the complement of the input image and do an end with the model and |
|
|
24:17 | the second part you take the complement the model and end it with the |
|
|
24:21 | . Okay, and then you take or between the result of these two |
|
|
24:26 | and you have what is called X or gate, Okay, and |
|
|
24:30 | you do that, you get something looks like this, it shows all |
|
|
24:34 | black pixels are deviations that is, know, they don't match up. |
|
|
24:40 | , now, once I have this , I can compute uh you know |
|
|
24:44 | one value to say what amount of has occurred, for example, if |
|
|
24:48 | are 100 pixels that are deviated and total there needs to be 1000 black |
|
|
24:54 | . So I can look at that and say the deviation is 10% and |
|
|
24:57 | can do some quality control single. it's more than 5% Reject that |
|
|
25:02 | Right. All right. So that's simple example where you can actually apply |
|
|
25:09 | operations between two whole images uh and actually useful to do it. |
|
|
25:14 | But more often in the things we , we tend to apply logical operations |
|
|
25:19 | smaller regions uh and use that output . All right. So before we |
|
|
25:32 | that, let's talk about an algorithm blob coloring. And like I |
|
|
25:38 | you know, when you're hissed a is not by model in nature. |
|
|
25:41 | is if it's multi model or if flat, you would end up either |
|
|
25:46 | some of the background pixels as foreground some of the foreground pixels background. |
|
|
25:51 | . So if you look at if I classify by some of the |
|
|
25:55 | pixels, foreground pixels, you would up with having some noise objects like |
|
|
26:01 | . Okay. On the other if there are foreground pixels and fight |
|
|
26:05 | them as background pixels, I would up having holes like this. |
|
|
26:10 | now these are all imperfections. I catch I've captured some information but |
|
|
26:15 | is not perfect. So I would to do additional operations to improve the |
|
|
26:20 | in the image and often times this is called us the region correction. |
|
|
26:24 | , you're correcting regions. So in case the object that I'm interested is |
|
|
26:29 | large object in the middle. The big one in the middle is |
|
|
26:33 | I'm interested. But all those little surrounding it are noise and all these |
|
|
26:39 | in the object are also errors. ? So I need to do region |
|
|
26:44 | to remove the noise and also do correction to remove those holes. |
|
|
26:49 | And one algorithm that helps us in this is called blob coloring. And |
|
|
26:55 | it does is it groups pixels together belong to an object. Okay. |
|
|
27:00 | if I look at the image for , right. If I look at |
|
|
27:03 | pixel values, I have a whole of zeros. I have a whole |
|
|
27:07 | of zeros wherever this object is. have once that's all the information I |
|
|
27:11 | but I do not know if these of ones belong to one particular |
|
|
27:15 | Right. Similarly, I do not if all of these ones belong to |
|
|
27:19 | particular object. Right. What I to do is I want to come |
|
|
27:23 | with an algorithm where the output is it says, Okay, object one |
|
|
27:28 | pixel X one Y one X Y two X three, Y |
|
|
27:32 | So and so forth. That is the pixel locations that belong to one |
|
|
27:36 | object are grouped together. Okay, is okay. Do you understand what |
|
|
27:42 | the output for block coloring? So this case if I say there are |
|
|
28:11 | objects then what I need to get output is when I apply blob coloring |
|
|
28:16 | this image, I need to get one and this should say okay, |
|
|
28:25 | XR one XRYR one. Right? is a pixel that belongs to this |
|
|
28:33 | . Right? And I need to X. uh all this one one |
|
|
28:41 | 12. Y 12 is another pixel belongs to this object. So on |
|
|
28:47 | the pixels that belong to that object I need to get our two but |
|
|
28:53 | all the pixels that belong to Okay, so basically I'm grouping pixels |
|
|
29:11 | belongs to one object together. Once I have this information I can |
|
|
29:15 | region correction because I know which one those who are noises and maybe I |
|
|
29:19 | just remove them. I know which or whole. Well, I don't |
|
|
29:22 | holds yet but we'll find a way do that. Okay, so now |
|
|
29:27 | do we do this is the question . How do we do block |
|
|
29:31 | And it's really important to understand this because it's more than likely to end |
|
|
29:35 | as an assignment. Okay, so coloring is basically a simple technique to |
|
|
29:46 | axles that belong to a certain object a blob blob is nothing but a |
|
|
29:52 | large object. Okay. All So let's start with something simple. |
|
|
29:57 | , in this case you have this object in the center that is with |
|
|
30:01 | the black pixels and right now my image basically has a bunch of zeros |
|
|
30:06 | the background and once for the pixel this object is. What I want |
|
|
30:11 | do is I want to write an where the where it will label each |
|
|
30:15 | of these ones as the label be it says, it belongs to the |
|
|
30:20 | . B Now can we write a algorithm to do that? That's |
|
|
31:11 | You want you? That's perfect. there's two ideas to what you've talked |
|
|
31:22 | . One is that there is a of iteration that I'm following. There |
|
|
31:27 | a direction of flowing. There is is at every point I'm making a |
|
|
31:31 | for each pixel. Right? So started the top left and I follow |
|
|
31:35 | follow a scanning mechanism for each Right? That way I can make |
|
|
31:40 | decision for each pixel and move on the next. That's one thing. |
|
|
31:44 | ? I'm doing the scanning. And second is that I'm also looking at |
|
|
31:48 | pixels that surround each one to decide it belongs to that or not. |
|
|
31:53 | . So there is also a sense neighborhood right now, neighborhoods can be |
|
|
31:58 | types. Right? I can define as being only the pixel on, |
|
|
32:03 | know, top of north south east west are the neighbors. That's a |
|
|
32:06 | for neighborhood or I can say not just north south east west, |
|
|
32:10 | can say north northeast. Um You east. You know so and so |
|
|
32:15 | . I get eight different pixels. I can even define bigger neighborhoods that |
|
|
32:20 | 25 pixels. Right? So there a definition for neighborhood as well. |
|
|
32:24 | . So there are two things I . One is a scanning mechanism for |
|
|
32:30 | pixel. And as I scan, make decisions for each pixel and move |
|
|
32:34 | . Okay. In our case the natural scanning mechanism is that start at |
|
|
32:39 | top left. Keep making decisions until end up until the until you reach |
|
|
32:43 | end of that column, go to next row. Start scanning again and |
|
|
32:46 | making decisions right now. Before I before I before I work look at |
|
|
32:52 | neighboring pixels. First thing I have do is I need to define a |
|
|
32:56 | . Right? And then I can check those pixels to see if they |
|
|
33:00 | already labeled or not. If they labeled. I can give the same |
|
|
33:04 | or I can um or I can have to create a new label. |
|
|
33:09 | , so in this case that's what do right. In this case actually |
|
|
33:13 | don't even have to do that because a very simple. Uh there's only |
|
|
33:17 | object essentially I can scan and at location. If I see it's a |
|
|
33:22 | , I can just give it Well I can just give it a |
|
|
33:25 | . B and I'll be good. I'm gonna run into issues when I |
|
|
33:29 | an image that kind of looks like because this one needs to get a |
|
|
33:34 | label than this object right now. this case at every point if that |
|
|
33:41 | is a one, I need to at its neighbors and if the neighbor |
|
|
33:45 | a label, it has to get same label as that neighbor. |
|
|
33:50 | All right. Russian. Alright. let's let's try to solve this |
|
|
34:01 | Right? Let's try to come up an algorithm for this. So let's |
|
|
34:05 | I start scanning right? As the order. Is that started top |
|
|
34:17 | Okay. So the scanning orders that at top left and I scan every |
|
|
34:22 | and make a decision for every Right? Making a decision means giving |
|
|
34:25 | a label right now. The first is that what's the first thing I |
|
|
34:29 | to check. Huh? Well, need to check if that pixel location |
|
|
34:40 | a zero or a one. If it's a zero, I don't |
|
|
34:43 | for it. Right? If it's one, I'll need to make a |
|
|
34:46 | on it. Right? So let's a few things. First thing is |
|
|
34:50 | let's call this image I Right. let's say there is also what's called |
|
|
34:55 | regions image. Okay, This is output image. I want to |
|
|
34:58 | That is just as big as that . Right? 12345678. Okay. |
|
|
35:46 | . Alright. So I start scanning that image in the top left. |
|
|
35:50 | are all zeros. So I don't anything right? All of these end |
|
|
35:54 | getting zeros right? And the next as well they all end up getting |
|
|
36:10 | . Now before I actually do I need to define a neighborhood. |
|
|
36:15 | . So let's say for this particular my neighborhood is a simple one that |
|
|
36:19 | looks at four pixels. That is , south and east and west. |
|
|
36:24 | , so for every pixel I define neighbors north, south, east and |
|
|
36:28 | . Those are the only four I have to check. Okay, |
|
|
36:31 | in the next one I keep Right? So this is zero. |
|
|
36:36 | don't care. This is zero. don't care. This is zero. |
|
|
36:38 | don't care. And then I come a one. Okay. And I |
|
|
36:41 | to define a label for this location my regions image. Right. Are |
|
|
36:46 | guys with me? Okay. So this case, what do I do |
|
|
36:53 | need to give it a region name . What do I get? All |
|
|
37:05 | , let's call something a region a variable that keeps count of |
|
|
37:10 | Okay, let's say start with the . Well too, I don't wanna |
|
|
37:15 | confuse between zero and one. so in this case I can simply |
|
|
37:20 | this value what the region number Right. So I can give it |
|
|
37:27 | two. And basically this is the when I have When I have this |
|
|
37:38 | filled with one right? And a and a zero in this case what |
|
|
37:43 | doing is that I'm saying region X Y is simply getting whatever is the |
|
|
37:52 | for the current region counter. Is that okay? Yes now so |
|
|
38:04 | course I need to check the condition if I X. Common Y is |
|
|
38:14 | to one. In which case I say region X comma Y would take |
|
|
38:21 | value of our Okay. Now since already used are the next time around |
|
|
38:27 | come across a situation like this. actually now this is the region I |
|
|
38:38 | this is the neighborhood that I created ? Which means I need to check |
|
|
38:41 | four pixels. Not just to I to check down in below as well |
|
|
38:45 | we're not doing that. Why? . We haven't gone that far. |
|
|
38:56 | don't have a region number for Right? Even if I check something |
|
|
39:00 | the regions inmates there's nothing there Right? Despite creating your neighborhood as |
|
|
39:06 | , these two are actually not going give you any information. Right? |
|
|
39:10 | that's the reason we only need to top and left because those are the |
|
|
39:14 | that are already scanned. Okay. . So when I come across this |
|
|
39:20 | I know what to do right now do I check this condition though? |
|
|
39:27 | is a condition where that this particular is true. And also if I |
|
|
39:37 | comma y minus one, this is to zero and I x minus one |
|
|
39:46 | Y. It's equal to zero. ? If these two are ones then |
|
|
39:50 | would have already made a decision on and given them some region number. |
|
|
39:54 | which case I would have to give the same. Right? Only in |
|
|
39:58 | case I would say region X comma is equal to R. Okay. |
|
|
40:05 | then what I continue scanning right, go to the next pixel. How |
|
|
40:12 | this case look like? I know a one here. Right. And |
|
|
40:28 | it looks like this is also Right in this case, what do |
|
|
40:32 | do? Now checking this condition would that I External y is equal to |
|
|
40:44 | and I x Come on. Why is equal to what 1? Right |
|
|
40:57 | this one as well and I x o X -1. Common. Y |
|
|
41:06 | equal to zero. Right? This the condition that responds to this. |
|
|
41:11 | in this case what do I I need to give the same label |
|
|
41:24 | to write or whatever is the one to it because it belongs to the |
|
|
41:27 | block. Right? So I need say odd. X comma y is |
|
|
41:35 | to out of XO Y -1. that okay? Yes. Now. |
|
|
41:47 | this will just get up two And do that assignment. Okay? And |
|
|
41:53 | keep going on I got 000 I a 00. And then I have |
|
|
42:01 | condition here which is basically that I XO Y is equal to one. |
|
|
42:13 | what I of x minus one comma equal to and I have XO Y |
|
|
42:25 | . Equal to what? What is 0? That's right and this is |
|
|
42:39 | comma y minus. Oh yeah X on. Oh no that's not too |
|
|
42:46 | . We're talking about this pixel this this one here. Oh wait I'm |
|
|
42:52 | . No you're right. So this both this is zero and this is |
|
|
42:56 | as well but we always see in condition which is this one? |
|
|
43:05 | So what do I do now? need to follow the same rules and |
|
|
43:13 | need to assign one of the value others. Right now, ideally this |
|
|
43:17 | to be incremental. Every time this is run I need to say r |
|
|
43:21 | equal to r plus one. The time around when I come across a |
|
|
43:24 | blob I give it a new region . Right? So if I do |
|
|
43:28 | , this gets a value three. , okay, so let's move |
|
|
43:36 | And the next the next pixel is interesting because both of them actually have |
|
|
43:44 | region number. Now this is a where I have I of X comma |
|
|
43:49 | is equal to one and I of -1. Common wide is equal to |
|
|
43:57 | and I have I of X comma minus one is equal to one. |
|
|
44:04 | ? This is a condition where this now. What do I do? |
|
|
44:25 | label should that get now? If look to the top it will tell |
|
|
44:31 | that I need to give it a to. If I looked at the |
|
|
44:37 | tell me that I need to give the label. Three. Right? |
|
|
44:45 | label should I give it? It's to give to which is fine. |
|
|
45:00 | it also tells me that the pixel the left also belongs to the same |
|
|
45:05 | as the one about right. They belong to the same blog, |
|
|
45:09 | All the pixels which means I don't which number I give as long as |
|
|
45:13 | give the same number to all of . Right. Does that make |
|
|
45:20 | So if this case occurs we need check that if the if this value |
|
|
45:26 | the one to do this. If value and this label are the same |
|
|
45:31 | ? If they are same, there's much to do. I just give |
|
|
45:34 | the value of our left us. only problem is when they are different |
|
|
45:39 | I just realized that all of these as three are the same as the |
|
|
45:44 | labeled as too. So I need go back check all the trees and |
|
|
45:49 | them to two or I can check the tools and change them to |
|
|
45:53 | Is that okay? So in this there's another if statement I say f |
|
|
46:01 | of x minus one comma y is to region of X comma Y minus |
|
|
46:10 | . Okay, now if this is , I can simply say R of |
|
|
46:15 | comma Y is basically equal to out X minus one comma Y or R |
|
|
46:20 | X comma Y. It doesn't matter they're the same value. Right? |
|
|
46:24 | if this is not true then I realized that all trees are same. |
|
|
46:32 | need to iterate through this right? I need to check if a value |
|
|
46:37 | three and change it to two. you guys Okay. So and else |
|
|
46:46 | be affects all trees to write. I started trading from here and check |
|
|
46:56 | values 00000222. I don't care. three. Change start to cool. |
|
|
47:06 | . And of course I'll give this the same value as stuff. It's |
|
|
47:14 | . Now I go to the next in which case this is the same |
|
|
47:20 | , right? In this case this statement is actually true. So it |
|
|
47:25 | the same value as the one to top. So this gets it to |
|
|
47:30 | ? All right. How about the one? Which condition is the next |
|
|
47:39 | ? This one right? In which I just give the value to the |
|
|
47:44 | and I get her to right and are all zeros. I don't |
|
|
47:50 | I don't care. And again, condition is this? We don't have |
|
|
47:58 | condition for this Right? There is 4th condition now and that condition is |
|
|
48:16 | right? So the fourth condition is i X comma y is equal to |
|
|
48:25 | . I X comma y minus one equal to one and I X comma |
|
|
48:35 | . Sorry X minus one, comma is equal to one and I X |
|
|
48:48 | y minus one is equal to Okay in this case what do I |
|
|
49:02 | ? You just give the value that to the top right? It's kind |
|
|
49:05 | very much like this. You instead would say out of out of X |
|
|
49:15 | Y is basically equal to out of minus one comma wife and you would |
|
|
49:25 | up getting a to hear? Alright. The next one. What's |
|
|
49:35 | next condition? Which condition is the 1? Sorry, this is this |
|
|
50:01 | right? And this is true for . So you just give it the |
|
|
50:04 | value as one of those right? the next one. So the next |
|
|
50:39 | is the same as a three and one is true. So I just |
|
|
50:44 | the same value as one of the left. This is also the same |
|
|
50:47 | as three and I do that. That's right. Yeah. So this |
|
|
50:55 | is also the same condition and these zeros right? And then I have |
|
|
51:02 | and then what do I have It's the fourth condition and I just |
|
|
51:11 | to assign the value above them. one is the same as this one |
|
|
51:17 | and it's true which is fine. I get 000. Okay. And |
|
|
51:24 | 0000 00. And there's one Which condition is this this one? |
|
|
51:36 | by this time March are has actually incremental too four. Right. So |
|
|
51:49 | arm was initially to I didn't want confuse between zeros and ones. And |
|
|
51:54 | first time when I got here it implemented to three. It became r |
|
|
51:58 | equal to three. And next time when when I hit the three it |
|
|
52:03 | implemented to four. Right? So time this one will get a value |
|
|
52:08 | . Right. Is that okay? now I can iterate through this image |
|
|
52:20 | I'll say okay all the pixels that a value to. I'll group them |
|
|
52:24 | one. All the pixels that get value three. I group them as |
|
|
52:28 | . There are no trees. All pixels that get a value for I'll |
|
|
52:31 | them as another one and I would group pixels that belong to the same |
|
|
52:36 | together. Okay. And also remember . This depends on your definition of |
|
|
52:42 | neighborhood. Right? This is one . I can also define a neighborhood |
|
|
52:47 | kind of looks like this A three 3 region for each one? I |
|
|
52:55 | to check more pixels. So in case what are the pixels that actually |
|
|
52:59 | me information in this case? So for that one the neighborhood I'm |
|
|
53:17 | is only top and the left. . Because the one on the right |
|
|
53:19 | the bottom don't give me any How about this one? But every |
|
|
53:24 | what are the pixels? I need check this is the one. I |
|
|
53:32 | to check this. This this So I need to write more conditions |
|
|
53:41 | check these. Okay, now I also depending on the application, I |
|
|
53:49 | also define a larger neighborhood which is . Sometimes it has maybe in your |
|
|
53:54 | it's common to have you know, pixel holds and things like that. |
|
|
53:59 | which case I define something larger. I would have to check all of |
|
|
54:07 | To actually make the decision for that pixel. Okay, now if I |
|
|
54:13 | to use this over here then I actually end up getting the same label |
|
|
54:17 | this pixel as the one about. . Mhm. Um it's well that |
|
|
54:36 | looks large but in reality it's not example if you think about megapixel images |
|
|
54:44 | have 1000 columns up and down. when you do been a realization of |
|
|
54:49 | , you may end up with a of holds objects that are actually really |
|
|
54:53 | that actually together men may be separated just one pixel and you may have |
|
|
54:57 | group them together. Right. So let's go back to what we |
|
|
55:07 | doing now. Again the idea is I need to do region correction. |
|
|
55:13 | ? And I said in order to region correction, my objective is that |
|
|
55:18 | need to remove the noise pixels and also have to remove the holes. |
|
|
55:23 | now I'm doing a blob coloring to group these pixels together because here I |
|
|
55:30 | the knowledge that the largest blob is one I care about and the |
|
|
55:34 | smaller blobs are just noise. I that knowledge, application knowledge. Now |
|
|
55:39 | can use that to remove the spectral noise uh objects. Right? |
|
|
55:47 | once I do block coloring, I what pixels belong to which blob. |
|
|
55:53 | ? And again, when you get chance, please go through this |
|
|
55:56 | it's it's really important and it is to be on the assignment and turning |
|
|
56:00 | into code would require a little bit time. Okay, so at the |
|
|
56:08 | of Blob covering this is what I for each set of pixels. I |
|
|
56:13 | region numbers. So essentially all those will get a region number one. |
|
|
56:16 | will get a region number 2345. now I can do accounting of |
|
|
56:22 | Right? So if I counted, turns out that little blob up there |
|
|
56:27 | 793 pixels. Right? This big has about 11,000 pixels and the other |
|
|
56:33 | has 1000 1 73 112 pixels. now I know that the biggest one |
|
|
56:40 | the one I care about. Um I can basically straight through that image |
|
|
56:46 | I'll say if the blob member of region number is equal to one, |
|
|
56:50 | it a zero. If the blob is equal to three make it to |
|
|
56:54 | . So I'll make everything zero except blob too. Right? And as |
|
|
56:59 | result I would have removed all the regions. Is it? Okay. |
|
|
57:06 | , perfect. Alright so once I that, all the smaller regions are |
|
|
57:29 | now I still have one more one problem to solve that. I need |
|
|
57:32 | remove those holes. How do we that already moved the holes. I |
|
|
58:06 | a way to remove smaller objects or right? I do block coloring, |
|
|
58:10 | remove the ones that have a low of pixels. Now how do I |
|
|
58:16 | the whole, I can take the of the image and then do block |
|
|
58:29 | on it. Right. And then again do the counting and remove smaller |
|
|
58:35 | . Right? So if I take compliment this is how it would look |
|
|
58:40 | . Now all that background is one blob right now ideally when I do |
|
|
58:46 | covering all of these will get one number and these smaller ones will get |
|
|
58:50 | different region number. Again I literate it and if this region number belongs |
|
|
58:55 | what other small blob is remove it . Once I do that I get |
|
|
59:05 | that looks like this, right? effectively we have done some amount of |
|
|
59:10 | correction where we removed noise objects in , Right? So this is also |
|
|
59:26 | you would do cell counting when you for a blood blood work, |
|
|
59:31 | You create these binary images. Uh then for that binary images, you |
|
|
59:36 | do block coloring, right? And you can remove noise, noise blobs |
|
|
59:40 | things like that. And then if look at the count of those |
|
|
59:44 | those basically is your white blood count red blood count. Okay, |
|
|
59:59 | this is okay. Um Alright, let's go ahead. And and the |
|
|
60:12 | here, we can pick it up . In next class. We can |
|
|
60:15 | about morphological operations and things like Mm I wrote them on |
|