CONNECTED COMPONENT ANALYSIS METHOD WHICH CAN REUSE LABEL
20230196717 · 2023-06-22
Assignee
Inventors
Cpc classification
G06V10/267
PHYSICS
G06V10/457
PHYSICS
International classification
G06V10/44
PHYSICS
Abstract
A connected component analysis (CCA) method, which can use labels repeatedly, comprising: defining a label pattern comprising a label and a plurality of neighboring labels; setting a center label of a current pixel of a target binary image according to a binary value of the current pixel and the neighboring pixels; setting at least two of the neighboring labels according to whether the current pixel is in any one of a first row, a first column and a last column; and recording the center label to a label buffer. Labels for marking pixels of the target binary image are first center labels, and then are second center labels, and are the first center labels again after the labels are the second center labels.
Claims
1. A connected component analysis method, which can use labels repeatedly, comprising: defining a label pattern comprising a center label and a plurality of neighboring labels; setting a label of a current pixel of a target binary image according to a binary value of the current pixel and the neighboring pixels; setting at least two of the neighboring labels according to whether the current pixel is in any one of a first row, a first column and a last column; and recording the center label to a label buffer; wherein labels for marking pixels of the target binary image are first center labels, and then are second center labels, and are the first center labels again after the labels are the second center labels.
2. The connected component analysis method of claim 1, further comprising: setting the center label to a new value if all of the neighboring labels are 0.
3. The connected component analysis method of claim 2, further comprising: setting the center label to the new value plus 1, if all of the neighboring labels are 0 again in a process of a next pixel.
4. The connected component analysis method of claim 1, further comprising: setting the center label to be a corresponding one of the neighboring labels if the corresponding one of the neighboring labels is larger than 0.
5. The connected component analysis method of claim 1, further comprising: limiting the center label to be lower than a maximum label threshold.
6. The connected component analysis method of claim 1, further comprising: setting the center label according to whether collision of used labels occurs, wherein the collision means some specific ones of the neighboring labels are notO and are different.
7. The connected component analysis method of claim 6, wherein the center label is set to a minimum one of specific ones of the neighboring labels when the collision occurs.
8. The connected component analysis method of claim 1, further comprising: replacing the center labels recorded in the label buffer with other values according to whether collision of used labels occurs.
9. The connected component analysis method of claim 8, wherein at least maximum one of specific ones of the neighboring labels is set to a minimum one of the specific ones of the neighboring labels when the collision occurs.
10. The connected component analysis method of claim 8, further comprising: setting the center label to a new value if all of the neighboring labels are 0; wherein the center label which is recorded in the label buffer and has a value of the new value minus one, is replaced by a maximum one of the specific ones of the neighboring labels when the collision of used labels occurs.
11. The connected component analysis method of claim 1, further comprising: recording numbers respectively for different ones of the center labels.
12. The connected component analysis method of claim 11, further comprising: computing size information related with a minimum one of specific ones of the neighboring labels, a maximum one of the specific ones of the neighboring labels, and a new label, to compute the size.
13. The connected component analysis method of claim 1, further comprising: recording centroid reference values for different center labels.
14. The connected component analysis method of claim 13, further comprising: computing centroid information related with a minimum one of specific ones of the neighboring labels, a maximum one of the specific ones of the neighboring labels, and a new label, to compute the centroid.
15. The connected component analysis method of claim 1, further comprising: recording bounding reference values for different ones of the center labels.
16. The connected component analysis method of claim 15, further comprising: computing bounding information related with a minimum one of specific ones of the neighboring labels, a maximum one of the specific ones of the neighboring labels, and a new label, to compute the bounding box.
17. The connected component analysis method of claim 1, wherein a number of bits that the label buffer can record is a number of columns of the target binary image plus 1.
18. An image sensor, comprising: a sensor array, outputting a binary image, wherein the binary image has M*N pixels, M>2 and N>3; and a processing circuit, receiving the binary image and processing the binary image to identify at least one object in the binary image through minimally labeling at least one object unit, wherein if the number of the least one object unit is X, the number of a corresponding label is X.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
[0010]
[0011]
[0012]
[0013]
DETAILED DESCRIPTION
[0014] Several embodiments are provided in following descriptions to explain the concept of the present invention. The method in following descriptions can be executed by programs stored in a non-transitory computer readable recording medium such as a hard disk, an optical disc or a memory. For example, the programs can be executed by a processing circuit. Additionally, the term “first”, “second”, “third” in following descriptions are only for the purpose of distinguishing different one elements, and do not mean the sequence of the elements.
[0015]
[0016] Also, the value of Lj may be used to determine at least one of La, Lb, Lc, Ld. Furthermore, La, Lb, Lc, Ld may affect each other. Please note, the flows in
[0017]
[0018] Step 101
[0019] Start.
[0020] Step 102
[0021] Set
[0022] new_label=1
[0023] num_blob=0
[0024] Blob means the connected components.
[0025] Step 103
[0026] Set
[0027] P=a pixel value of the first pixel
[0028] Step 104
[0029] Set Collision=0
[0030] In one embodiment, collision means some specific neighboring labels have different values besides 0 [FIG.1: Arrow from 148 should be connected to 104, not 105].
[0031] Step 105
[0032] Determine if P=0, go to step 106_1 if the answer is no, and go to step 106_2 if the answer is yes [
[0033] Step 106_1
[0034] Determine if a current pixel is in a first row, go to step 107 if the answer is yes, and go to step 108 if the answer is no.
[0035] Step 106_2
[0036] Set Lj=0
[0037] Step 107
[0038] Set La=0, Lb=0, Lc=0
[0039] Step 108
[0040] Set Lb=Top label.
[0041] The top label means a top label of Lj stored in a label buffer [In
[0042] Step 109
[0043] Determine if the current pixel is in a first column, go to step 111 if the answer is yes, and go to step 110 if the answer is no.
[0044] Step 110
[0045] Determine if the current pixel is in a last column, go to step 112 if the answer is yes, and go to step 113 if the answer is no.
[0046] Step 111
[0047] Set La=0, Lc=Top right label, Ld=0
[0048] The top right label means a top right label of Lj stored in the label buffer.
[0049] Step 112
[0050] Set La=Top Left Label, Lc=0, Ld=Left Label
[0051] The top left label means a top left label of Lj stored in the label buffer.
[0052] The left label means a left label of Lj stored in the label buffer.
[0053] Step 113
[0054] Set La=Top Left Label, Lc=Top right label, Ld=Left Label
[0055] Step 114
[0056] Determine if La>0 and Lc>0, go to step 115 if the answer is yes, and go to step 118 if the answer is no.
[0057] Step 115
[0058] Determine if La=Lc, go to step 116 if the answer is yes, and go to step 117 if the answer is no.
[0059]
[0060] Step 116
[0061] Set Lj=La
[0062] Step 117
[0063] Set
[0064] Collision=1
[0065] Lmin=min(La, Lc)
[0066] Lmax=max(La, Lc)
[0067] Step 118
[0068] Determine if Lc>0 and Ld>0, go to step 119 if the answer is yes, and go to step 122 if the answer is no.
[0069] Step 119
[0070] Determine if Lc=Ld, go to step 120 if the answer is yes, and go to step 121 if the answer is no.
[0071] Step 120
[0072] Set Lj=Lc
[0073] Step 121
[0074] Set Collision=1
[0075] Lmin=min(Lc, Ld)
[0076] Lmax=max(Lc, Ld)
[0077] Step 122
[0078] Determine if La, Lb, Lc and Ld are 0, go to step 123 if the answer is yes, and go to step 126 if the answer is no.
[0079] Step 123
[0080] Set
[0081] num_blob=num_blob+1
[0082] Lj=new_label new_label=num_label+1
[0083] Step 124
[0084] Determine if the new label (the new label set in step 123) is larger than a maximum label, go to step 125 if the answer is yes, and go to step 133 if the answer is no.
[0085] Step 125
[0086] Set the new label to be a value of a maximum label stored in the label buffer.
[0087] Step 126
[0088] Determine if La is larger than 0, go to step 127 if the answer is yes, and go to step 128 if the answer is no.
[0089] Step 127
[0090] Set Lj=La
[0091] Step 128
[0092] Determine if Lb is larger than 0, go to step 129 if the answer is yes, and go to step 130 if the answer is no.
[0093] Step 129
[0094] Set Lj=Lb
[0095]
[0096] Step 130
[0097] Determine if Lc is larger than 0, go to step 131 if the answer is yes, and go to step 132 if the answer is no.
[0098] Step 131
[0099] Set Lj=Lc
[0100] Step 132
[0101] Set Lj=Ld
[0102] Step 133
[0103] Determine if Collision=1, go to step 134 if the answer is yes, and go to step 141 if the answer is no.
[0104] Step 134
[0105] Set Lj to Lmin
[0106] Step 135
[0107] Replace all Lmax in the label buffer to Lmin.
[0108] Lmax means the maximum label (s) of specific ones of neighboring labels, and Lmin means the minimum label(s) of specific ones of the neighboring labels.
[0109] Step 136
[0110] Replace all (new_label-1) in the label buffer with Lmax [
[0111] For example, if the new_label is 2, than all labels 1 in the label buffer are replaced with Lmax.
[0112] Step 137
[0113] Set Featsize [Lmin]=FeatSize[Lmin]+FeatSize[Lmax]+1
[0114] Set Featsize [Lmax]=FeatSize [new label-1]
[0115] Set FeatSize [new label-1]=0
[0116] These steps are applied for computing numbers respectively for different center labels, to compute sizes for different center labels [Actually all the blobs within the target binary image are having the same binary value of “1”. The size computed here refer to the blobs size within the binary image, where each blob has its own label and size]. Other steps having FeatSize are for the same purpose.
[0117] Step 138
[0118] Set
[0119] FeatCent [Lmin]=FeatCent[Lmin]+FeatCent[Lmax]+[row, col] [
[0120] FeatCent [Lmax]=FeatCent [new_label-1]
[0121] FeatCent [new_label-1]=0 [row, col] means a row address and a column address of the current pixel.
[0122] These steps are applied for recording centroid reference values for different center labels [Similar comment for Step 137]. Other steps having FeatCent are for the same purpose.
[0123] Step 139
[0124] This step is used for recording bounding reference values for different center labels. Other steps having FeatBbox are for the same purpose.
[0125] Detail steps are as below:
[0126] Set
[0127] FeatBboxLeft[Lmin]=min(FeatBboxLeft[Lmin], FeatBboxLeft[Lmax], col)
[0128] FeatBboxRight[Lmin]=max(FeatBboxRight[Lmin], FeatBboxRight [Lmax], col)
[0129] FeatBboxTop[Lmin]=min(FeatBboxTop[Lmin], FeatBboxTop[Lmax], row)
[0130] FeatBboxBottom[Lmin]=min(FeatBboxBottom[Lmin], FeatBboxBottom[Lmax], row)
[0131] FeatBboxLeft[Lmax]=FeatBboxLeft[new_label-1]
[0132] FeatBboxRight[Lmax]=FeatBboxRight[new_label-1]
[0133] FeatBboxTop[Lmax]=FeatBboxTop[new_label-1]
[0134] FeatBboxBottom[Lmax]=FeatBboxBottom[new_label-1]
[0135] FeatBboxLeft[new_label-1]=0
[0136] FeatBboxRight[new_label-1]=0
[0137] FeatBboxTop[new_label-1]=0
[0138] FeatBboxBottom[new_label-1]=0
[0139] Step 140
[0140] Set
[0141] num_blob=num_blob-1
[0142] new_label=new_label-1
[0143] Step 141
[0144] Set
[0145] FeatSize[Lj]=FeatSize[Lj]+1
[0146] Step 142
[0147] Set
[0148] FeatCent[Lj]=FeatCent[Lj]+[row, col]
[0149] Step 143
[0150] Determine if FeatSize[Lj] is 1, go to step 146 if the answer is yes, and go to step 145 if the answer is no.
[0151] Step 144
[0152] Set
[0153] FeatBboxLeft[Lj]=col
[0154] FeatBboxRight[Lj]=col
[0155] FeatBboxTop[Lj]=row
[0156] FeatBboxBottom[Lj]=row
[0157] Step 145
[0158] Set
[0159] FeatBboxLeft[Lj]=min(FeatBboxLeft[Lj],col)
[0160] FeatBboxRight[Lj]=max(FeatBboxRight[Lj],col)
[0161] FeatBboxTop[Lj]=min(FeatBboxTop[Lj],row)
[0162] FeatBboxBottom[Lj]=max(FeatBboxBottom[Lj],row)
[0163] Step 146
[0164] Record Lj to label buffer
[0165] Step 147
[0166] Determine if the current pixel is the last pixel, go to step 149 if the answer is yes, and go to step 148 if the answer is no.
[0167] Step 148
[0168] Set P=a pixel value of a next pixel, and goes back to the step 104 to process next pixel.
[0169] Step 149
[0170] End
[0171] As stated above,
[0172] The steps in
[0173]
[0174] Step 1
[0175] The pixel at (R1, C1) has a pixel value of 0, thus Lj=0 and Lj is stored to the label buffer (R1, C1). It also means the pixel at (R1, C1) is marked by the center label 0.
[0176] Feature table (area) , the feature table (Centroid) and feature table (Bounding Box) are correspondingly set to be 0. For more detail, all feature tables value are reset or initialized to 0 for every new image, before the first pixel is processed. Therefore, in this steps, the pixel at (R1, C1) has a pixel value of 0, thus feature tables (already initialized to 0) will not be updated.
[0177] Step 2
[0178] (a) The pixel at (R1, C1) has a pixel value of 1.
[0179] The current pixel is in first row, thus La=Lb=Lc=0.
[0180] (b) The current pixel is not in a first column or a last column, La=Top Left Label=predetermine value=0, Lc=Top Right Label=predetermine value=0, Ld=left label=0.
[0181] In the step 2, Top Left Label and Top Right Label of the center label 1 do not exist, thus La, Lc are set to a predetermined value 0.
[0182] (c)Since La=Lb=Lc=0
[0183] Lj=new label=1, the new_label here is an initial new_label.
[0184] new_label=new_label+1=2
[0185] new_label is less than a max_label, so new_label=2. In this step, the max_label is an initial value 4, thus the new_label 2 is less than the max_label.
[0186] For more detail, the max_label refers to the maximum number of label and it depends on the memory size allocated for feature tables. Bigger max_label meaning bigger memory size is required to store more labels (1 label for each object/blob). For this particular target binary image example, max_label has to be set to minimally 4 in order to process the image correctly. Any new_label that is greater than 4 will be clipped to 4. By using max_label of 4 for this example, each feature table(size, centroid and bounding box) will be able to store information for up to 3 objects/blobs.
[0187] num_of_object=num_of_object+1=0+1=1
[0188] num_of_object is the num_of_blob in
[0189] (d)No collision occurs
[0190] Size[1]=Size[1]+1=1, the initial Size[1]=0. The Size[] means the FeatSize[] in the steps of
[0191] FeatCent[1]=FeatCent[1]+[1,2]=[1,2], the initial FeatCent[1]=0.
[0192] Size[1]=1, then
[0193] BboxLeft[1]=Col=2
[0194] BboxRight[1]=Col=2
[0195] BboxTop[1]=Row=1
[0196] BboxBottom[1]=Row=1
[0197] (e) Record Lj=1 to label buffer (R1, C1)
[0198] Step 3
[0199] (a) The pixel at (R1, C3) has a pixel value of 1.
[0200] The current pixel is in a first row, thus La=Lb=Lc=0.
[0201] (b) The current pixel is not in a first column or a last column, La=Top Left Label=predetermine value=0, Lc=Top Right Label=predetermine value=0, Ld=left label=1.
[0202] (c) Lj=Ld=1
[0203] (d)No collision occurs
[0204] Size[1]=Size[1]+1=2.
[0205] FeatCent[1]=FeatCent[1]+[1,3]=[1,2]+[1,3]=[2,5]
[0206] BboxLeft[1]=min(BboxLeft[1], col)=min(2,3)=2
[0207] BboxRight[1]=max(BboxRight[1], col)=max(2,3)=2
[0208] BboxTop[1]=min(BboxTop[1], row)=min(1,1)=1
[0209] BboxBottom[1]=max(Bboxbottom[1], row)=max(1,1)=1
[0210] (e) Record Lj=1 to label buffer (R1, C3)
[0211] Step 4
[0212] The pixel at (R1, C4) has a pixel value of 0, thus Lj=0 and Lj is stored to the label buffer (R1, C4). Feature table (area), the feature table (Centroid) and feature table (Bounding Box) are not changed.
[0213]
[0214] Step 5
[0215] The pixel at (R1, C5) has a pixel value of 0, thus Lj=0 and Lj is stored to the label buffer (R1, C5). Feature table (area), the feature table (Centroid) and feature table (Bounding Box) are not changed.
[0216] Step 6
[0217] (a) The pixel at (R1, C6) has a pixel value of 1.
[0218] The current pixel is in first row, thus La=Lb=Lc=0.
[0219] (b) The current pixel is not in a first column or a last column, La=Top Left Label=predetermine value=0, Lc=Top Right Label=predetermine value=0, Ld=left label=Label buffer (R1,C6)=0.
[0220] (c)Since La=Lb=Lc=0
[0221] Lj=new_label=2
[0222] new_label=new_label+1=2+1=3
[0223] new_label is less than a max_label, so new label=3
[0224] num_of_object=num_of_object+1=1+1=2
[0225] (d)No collision occurs
[0226] Size[2]=Size[2]+1=1, the initial Size[2]=0.
[0227] FeatCent[2]=FeatCent[2]+[1,6]=[1,6], the initial FeatCent[2]=0.
[0228] Size[2]=1, then
[0229] BboxLeft[2]=Col=6
[0230] BboxRight[2]=Col=6
[0231] BboxTop[2]=Row=1
[0232] BboxBottom[2]=Row=1
[0233] (e) Record Lj=2 to label buffer (R1, C6)
[0234] Step 7
[0235] The pixel at (R1, C7) has a pixel value of 0, thus Lj=0 and Lj is stored to the label buffer (R1, C7). Feature table (area), the feature table (Centroid) and feature table (Bounding Box) are not changed.
[0236] Step 8
[0237] (a) The pixel at (R1, C8) has a pixel value of 1.
[0238] The current pixel is in a first row, thus La=Lb=Lc=0.
[0239] (b) The current pixel is in a last column, La=Top Left Label=predetermine value=0, Lc=0, Ld=left label=Label buffer (R1, C7) =0.
[0240] (c)Since La=Lb=Lc=Ld=0
[0241] Lj=new_label=3
[0242] new_label=new_label+1=3+1=4
[0243] new_label is less than a max_label, so new_label=4 [Same comment for Step 2 (c) above]
[0244] num_of_object=num_of_object+1=2+1=3
[0245] (d)No collision occurs
[0246] Size[3]=Size[3]+1=1, the initial Size[3]=0.
[0247] FeatCent[3]=FeatCent[3]+[1,8]=[1,8]. The initial FeatCent[3]=0.
[0248] Size[3]=1, then
[0249] BboxLeft[2]=Col=8
[0250] BboxRight[2]=Col=8
[0251] BboxTop[2]=Row=1
[0252] BboxBottom[2]=Row=1
[0253] (e) Record Lj=3 to label buffer (R1, C8)
[0254] FIG.7 comprises following steps:
[0255] Step 9
[0256] (a) The pixel at (R2, Cl) has a pixel value of 1.
[0257] Lb=Top label=Label buffer (R1, C1)=0.
[0258] (b) The current pixel is not in a first row but in a first column, thus La=O, Lc=Top Right label=Label buffer (R1, C1)=1, Ld=0.
[0259] (c) Lc>0, Lj=Lc=1
[0260] (d)No collision occurs
[0261] Size[1]=Size[1]+2=3
[0262] FeatCent[1]=FeatCent[1]+[2,1]=[2,5]+[2,1]=[4,6].
[0263] BboxLeft[1]=min(BboxLeft[1], col)=min(2,1)=1
[0264] BboxRight[1]=max(BboxRight[1], col)=max(3,1)=3
[0265] BboxTop[1]=min(BboxTop[1], row)=min(1,2)=1
[0266] BboxBottom[1]=max(Bboxbottom[1], row)=max(1,2)=2
[0267] (e) Record Lj=1 to label buffer (R2, Cl)
[0268] Step 10
[0269] (a) The pixel at (R2, C2) has a pixel value of 1.
[0270] Lb=Top label=Label buffer (R1, C1)=1.
[0271] (b) The current pixel is not in first row and not in first column, thus La=Top Left label=Label buffer (R1, C1)=0, Lc=Top Right label=Label buffer (R1, C3)=1, Ld=Left label=Label buffer (R2, C1)=1.
[0272] (c) Lc>0 and Ld>0, and Lc=Ld
[0273] Lj=Lc=1
[0274] (d)No collision occurs
[0275] Size[1]=Size[1]+1=3+1=4
[0276] FeatCent[1]=FeatCent[1]+[2,2]=[4,6]+[2,2]=[6,8].
[0277] BboxLeft[1]=min(BboxLeft[1], col)=min(1,2)=1
[0278] BboxRight[1]=max(BboxRight[1], col)=max(3,2)=3
[0279] BboxTop[1]=min(BboxTop[1], row)=min(1,2)=1
[0280] BboxBottom[1]=max(Bboxbottom[1], row)=max(2,2)=2
[0281] (e) Record Lj=1 to label buffer (R2, C2)
[0282] Step 11
[0283] (a) The pixel at (R2, C3) has a pixel value of 1.
[0284] Lb=Top label=Label buffer (R1, C3)=1.
[0285] (b) The current pixel is not in first row and not in first column, thus La=Top Left label=Label buffer (R1, C1)=1, Lc=Top Right label=Label buffer (R1, C4)=0, Ld=Left label=Label buffer (R2, C2)=1.
[0286] (c) La>0
[0287] Lj=La=1
[0288] (d)No collision occurs
[0289] Size[1]=Size[1]+1=4+1=5
[0290] FeatCent[1]=FeatCent[1]+[2,3]=[6,8]+[2,3]=[8,11].
[0291] BboxLeft[1]=min(BboxLeft[1], col)=min(1,3)=1
[0292] BboxRight[1]=max(BboxRight[1], col)=max(3,3)=3
[0293] BboxTop[1]=min(BboxTop[1], row)=min(1,2)=1
[0294] BboxBottom[1]=max(Bboxbottom[1], row)=max(2,2)=2
[0295] (e) Record Lj=1 to label buffer (R2, C3)
[0296] Please note, in the embodiment of
[0297] Therefore, from step 11, the previously recorded labels are removed such that the label buffer stores only 9 labels.
[0298] Step 12
[0299] The rules of step 12 are similar with which of step 11, thus are omitted for brevity here.
[0300]
[0301] Step 13
[0302] The rules of step 13 are similar with which of the step 4, thus are omitted for brevity here.
[0303] Step 14
[0304] (a) The pixel at (R2, C6) has a pixel value of 1.
[0305] Lb=Top label=Label buffer (R1, C6)=2.
[0306] (b) The current pixel is not in first row and not in first column, thus La=Top Left label=Label buffer (R1, C5)=0, Lc=Top Right label=Label buffer (R1, C7)=0, Ld=Left label=Label buffer (R2, C5)=0.
[0307] (c) Lb>0
[0308] Lj=Lb=2
[0309] (d)No collision occurs
[0310] Size[2]=Size[2]+1=1+1=2
[0311] FeatCent[2]=FeatCent[2]+[2,6]=[1,6]+[2,6]=[3,12].
[0312] BboxLeft[2]=min(BboxLeft[2], col)=min(6,6)=6
[0313] BboxRight[2]=max(BboxRight[2], col)=max(6,6)=6
[0314] BboxTop[2]=min(BboxTop[2], row)=min(1,2)=1
[0315] BboxBottom[2]=max(Bboxbottom[2], row)=max(1,2)=2
[0316] (e) Record Lj=2 to label buffer (R2, C6)
[0317] Step 15
[0318] The rules of step 15 are similar with which of the step 4, thus are omitted for brevity here.
[0319] Step 16
[0320] (a) The pixel at (R2, C8) has a pixel value of 1.
[0321] Lb=Top label=Label buffer (R1, C8)=3.
[0322] (b) The current pixel is not in first row and is in a last column, thus La=Top Left label=Label buffer (R1, C7)=0, Lc=0, Ld=Left label=Label buffer (R2, C7)=0.
[0323] (c) Lb>0
[0324] Lj=Lb=3
[0325] (d)No collision occurs
[0326] Size[3]=Size[3]+1=1+1=2
[0327] FeatCent[3]=FeatCent[3]+[2,8]=[1,8]+[2,8]=[3,16].
[0328] BboxLeft[3]=min(BboxLeft[3], col)=min(8,8)=8
[0329] BboxRight[3]=max(BboxRight[3], col)=max(8,8)=8
[0330] BboxTop[3]=min(BboxTop[3], row)=min(1,2)=1
[0331] BboxBottom[3]=max(Bboxbottom[3], row)=max(1,2)=2
[0332] (e) Record Lj=3 to label buffer (R2, C8)
[0333] FIG.9 comprises following steps:
[0334] Step 17
[0335] The rules of step 17 are similar with which of the step 1, thus are omitted for brevity here.
[0336] Step 18
[0337] (a) The pixel at (R3, C2) has a pixel value of 1.
[0338] Lb=Top label=Label buffer (R2, C2)=1.
[0339] (b) The current pixel is not in first row and not in first column, thus La=Top Left label=Label buffer (R2, C1)=1, Lc=Top Right label=Label buffer (R2, C3)=1, Ld=Left label=Label buffer (R3, C1)=0.
[0340] (c) La>0, Lc>0, La=Lc
[0341] Lj=La=1
[0342] (d)No collision occurs
[0343] Size[1]=Size[1]+1=6+1=7
[0344] FeatCent[1]=FeatCent[1]+[3,2]=[10,15]+[3,2]=[13,17].
[0345] BboxLeft[1]=min(BboxLeft[1], col)=min(1,2)=1
[0346] BboxRight[1]=max(BboxRight[1], col)=max(4,2)=4
[0347] BboxTop[1]=min(BboxTop[1], row)=min(1,3)=1
[0348] BboxBottom[1]=max(Bboxbottom[1], row)=max(2,3)=3
[0349] (e) Record Lj=1 to label buffer (R3, C2)
[0350] Step 19
[0351] The rules of step 19 are similar with which of the step 18, thus are omitted for brevity here.
[0352] Step 20
[0353] The rules of step 20 are similar with which of the step 18, thus are omitted for brevity here.
[0354] In the steps 1-20, the center label Lj gradually increases but is less than the maximum label. Specifically, the center label Lj gradually increases from 1 to 3 but is less than 4.
[0355]
[0356] Step 21
[0357] (a) The pixel at (R3, C5) has a pixel value of 1.
[0358] Lb=Top label=Label buffer (R2, C5)=0.
[0359] (b) The current pixel is not in first row and not in first column, thus La=Top Left label=Label buffer (R2, C4)=1, Lc=Top Right label=Label buffer (R2, C6)=2, Ld=Left label=Label buffer (R3, C4)=1.
[0360] (c)Lc>0, Ld>0, but Lc, Ld are different
[0361] Collision=1
[0362] Lmin=min(Lc, Ld)=1
[0363] Lmax=max(Lc,Ld)=2
[0364] (d) Collision exists
[0365] (i) Lj=Lmin=1
[0366] (ii) Replace Lmax in the label buffer with Lmin
[0367] (iii)Replace label=new_label-1 or label=3 in label buffer with
[0368] Lmax or 2.
[0369] (iv)Size[Lmin]=Size[Lmin]+Size[Lmax]+1
[0370] .fwdarw.Size[1]+Size[2]+1=9+2+1=12
[0371] Size[Lmax]=Size[new_label-1].fwdarw.22 Size[2]=Size[3]=2
[0372] Size [new_label-1]=0.fwdarw.Size [3]=0
[0373] (v)FeatCent[Lmin]=FeatCent[Lmin]+FeatCent[Lmax]+[3,5]
[0374] .fwdarw.FeatCent[1]+FeatCent[2]+[3,5]
[0375] .fwdarw.[19,24]+[3,12] +[3,5]=[25,41]
[0376] FeatCent [Lmax]=FeatCent [new_label-1]
[0377] .fwdarw.FeatCent [2]=FeatCent [3]=[3,16]
[0378] FeatCent [new_label-1]=04 FeatCent [3]=0
[0379] (Vi)
[0380] FeatBboxLeft[Lmin]=
[0381] min(FeatBboxLeft[Lmin], FeatBboxLeft[Lmax], col)
[0382] .fwdarw.FeatBboxLeft[1]=min(1,6,5)=1
[0383] FeatBboxRight[Lmin]=
[0384] max(FeatBboxRight[Lmin], FeatBboxRight [Lmax], col)
[0385] .fwdarw.FeatBboxRight[1]=max[4,6,5]=6
[0386] FeatBboxTop[Lmin]=
[0387] min(FeatBboxTop[Lmin], FeatBboxTop[Lmax], row)
[0388] .fwdarw.FeatBboxTop[1]=min[1,1,3]=1
[0389] FeatBboxBottom[Lmin]=
[0390] min(FeatBboxBottom[Lmin], FeatBboxBottom[Lmax], row)
[0391] .fwdarw.FeatBboxBottom[l]=max(3,2,3)=3
[0392] FeatBboxLeft[Lmax]=FeatBboxLeft[new_label-1]
[0393] .fwdarw.FeatBboxLeft[2]=FeatBboxLeft[3]=8
[0394] FeatBboxRight[Lmax]=FeatBboxRight[new_label-1]
[0395] .fwdarw.FeatBboxRight[2]=FeatBboxRight[3]=8
[0396] FeatBboxTop[Lmax]=FeatBboxTop[new_label-1]
[0397] .fwdarw.FeatBboxTop[2]=FeatBboxTop[3]=1
[0398] FeatBboxBottom[Lmax]=FeatBboxBottom[new_label-1]
[0399] .fwdarw.FeatBboxBottom[2]=FeatBboxBottom [3]=2
[0400] FeatBboxLeft[new_label-1]=0.fwdarw.
[0401] FeatBboxLeft[3]=0
[0402] FeatBboxRight[new_label-1]=0.fwdarw.
[0403] FeatBboxRight[3]=0
[0404] FeatBboxTop[new_label-1]=0.fwdarw.
[0405] FeatBboxTop[3]=0
[0406] FeatBboxBottom[new_label-1]=0.fwdarw.
[0407] BeatBboxBottom[3]=0
[0408] (vii)
[0409] new_label=new_label-1=4-1=3
[0410] (viii)
[0411] num_of_object=number_of_object-1=3-1=2
[0412] (ix)
[0413] (e) Record Lj=1 to label buffer (R3, C5)
[0414] In the step 21, the pixel which is marked by the label 3 is changed to the label 1, thus the Feature Table (Area), Feature Table (Centroid) and the Feature Table (Bounding Box) are correspondingly changed. Therefore, in the step 21, the label 1 is reused.
[0415] Step 22
[0416] (a) The pixel at (R3, C6) has a pixel value of 1.
[0417] Lb=Top label=Label buffer (R2, C6)=1.
[0418] (b) The current pixel is not in first row and not in first column, thus La=Top Left label=Label buffer (R2, C5)=0, Lc=Top Right label=Label buffer (R2, C7)=0, Ld=Left label=Label buffer (R3, C5)=1.
[0419] (c) Lb>0
[0420] Lj=Lb=1
[0421] (d)No collision occurs
[0422] Size[1]=Size[1]+1=1+1=2
[0423] FeatCent[1]=FeatCent[1]+[3,6]=[25,41]+[3,6]=[28,47].
[0424] BboxLeft[1]=min(BboxLeft[1], col)=min(1,6)=1
[0425] BboxRight[1]=max(BboxRight[1], col)=max(6,6)=6
[0426] BboxTop[1]=min(BboxTop[1], row)=min(1,3)=1
[0427] BboxBottom[1]=max(Bboxbottom[1], row)=max(3,3)=3
[0428] (e) Record Lj=1 to label buffer (R3, C6)
[0429] Step 23
[0430] (a) The pixel at (R3, C7) has a pixel value of 1.
[0431] Lb=Top label=Label buffer (R2, C7)=0.
[0432] (b) The current pixel is not in first row and not in first column, thus La=Top Left label=Label buffer (R2, C6)=1, Lc=Top Right label=Label buffer (R2, C8)=2, Ld=Left label=Label buffer (R3, C6)=1.
[0433] (c)La>0, Lc>0, but La, Lc are different
[0434] Collision=1
[0435] Lmin=min(Lc, Ld)=1
[0436] Lmax=max (Lc, Ld) =2
[0437] (d) Collision exists
[0438] (i) Lj=Lmin=1
[0439] (ii) Replace Lmax in the label buffer with Lmin
[0440] (iii)Replace label=new_label-1 or label=2 in label buffer with
[0441] Lmax or 2.
[0442] (iv)Size[Lmin]=Size[Lmin]+Size[Lmax]+1
[0443] .fwdarw.Size[1]+Size[2]+1=13+2+1=16
[0444] Size[Lmax]=Size[new_label-1].fwdarw.Size[2]=2
[0445] Size [new_label-1]=0.fwdarw. Size [2]=0
[0446] (v)FeatCent[Lmin]=FeatCent[Lmin]+FeatCent[Lmax]+[3,7]
[0447] FeatCent[1]+FeatCent[2]+[3,7]
[0448] .fwdarw.[28,47]+[3,16] +[3,7]=[34,70]
[0449] FeatCent [Lmax]=FeatCent [new_label-1]
[0450] .fwdarw.FeatCent [2]=FeatCent [3]=[3,16]
[0451] FeatCent [new_label-1]=0 .fwdarw.FeatCent [2]=0
[0452] (Vi)
[0453] FeatBboxLeft[Lmin]=
[0454] min(FeatBboxLeft[Lmin], FeatBboxLeft[Lmax], col)
[0455] .fwdarw.FeatBboxLeft[1]=min(1,8,7)=1
[0456] FeatBboxRight[Lmin]=
[0457] max(FeatBboxRight[Lmin], FeatBboxRight [Lmax], col)
[0458] .fwdarw.FeatBboxRight[1]=max[6,8,7]=8
[0459] FeatBboxTop[Lmin]=
[0460] min(FeatBboxTop[Lmin], FeatBboxTop[Lmax], row)
[0461] .fwdarw.FeatBboxTop[1]=min[1,1,3]=1
[0462] FeatBboxBottom[Lmin]=min(FeatBboxBottom[Lmin], FeatBboxBottom[Lmax], row)
[0463] .fwdarw.FeatBboxBottom[1]=max(3,2,3)=3
[0464] FeatBboxLeft[Lmax]=FeatBboxLeft[new_label-1]
[0465] .fwdarw.FeatBboxLeft [2 ] =8
[0466] FeatBboxRight[Lmax]=FeatBboxRight[new_label-1]
[0467] .fwdarw.FeatBboxRight[2]=8
[0468] FeatBboxTop[Lmax]=FeatBboxTop[new_label-1]
[0469] .fwdarw.FeatBboxTop[2]=1
[0470] FeatBboxBottom[Lmax]=FeatBboxBottom[new_label-1]
[0471] .fwdarw.FeatBboxBottom[2]=2
[0472] FeatBboxLeft[new_label-l]=0.fwdarw.
[0473] FeatBboxLeft[2]=0
[0474] FeatBboxRight[new_label-l]=0.fwdarw.
[0475] FeatBboxRight[2]=0
[0476] FeatBboxTop[new_label-1]=0.fwdarw.
[0477] FeatBboxTop[2]=0
[0478] FeatBboxBottom[new_label-1]=0.fwdarw.
[0479] BeatBboxBottom[2]=0
[0480] (vii)
[0481] new_label=new_label-1=3-1=2
[0482] (viii)
[0483] num_of_object=number_of_object-1=2-1=1
[0484] (xi)
[0485] (e) Record Lj=1 to label buffer (R3, C7)
[0486] In the step 23, the pixel which is marked by the label 2 is changed to the label 1, thus the Feature Table (Area), Feature Table (Centroid) and the Feature Table (Bounding Box) are correspondingly changed.
[0487] Step 24
[0488] (a) The pixel at (R3, C8) has a pixel value of 1.
[0489] Lb=Top label=Label buffer (R2, C8)=1.
[0490] (b) The current pixel is not in first row and is in a last column, thus La=Top Left label=Label buffer (R2, C7)=0, Lc=0, Ld=Left label=Label buffer (R3, C7)=1.
[0491] (c) Lb>0
[0492] Lj=Lb=1
[0493] (d)No collision occurs
[0494] Size[1]=Size[1]+1=16+1=17
[0495] FeatCent[1]=FeatCent[1]+[3,8]=[34,70]+[3,8]=[37,78].
[0496] BboxLeft[1]=min(BboxLeft[1], col)=min(1,8)=1
[0497] BboxRight[1]=max(BboxRight[1], col)=max(8,8)=8
[0498] BboxTop[1]=min(BboxTop[1], row)=min(1,3)=1
[0499] BboxBottom[1]=max(Bboxbottom[1], row)=max(3,3)=3
[0500] (e) Record Lj=1 to label buffer (R3, C8)
[0501] In the step 24, all labels are changed to 1, and the process ends since (R3, C8) is the final pixel.
[0502] Please note, in the above steps, the centroid coordinate [row,column] for the object can be computed by dividing FeatCent by FeatSize. For example, in the step 24, the centroid coordinate [row,column] for the object can be shown as
[Actual coordinate [row,column] for each blob can be computed by dividing FeatCent by FeatSize as shown below:
[0503] A CCA method disclosed by above mentions embodiments can be summarized to have following steps:
[0504] defining a label pattern comprising a center label and a plurality of neighboring labels (e.g., the first label pattern LP1);
[0505] setting a label of a current pixel of a target binary image according to a binary value of the current pixel and the neighboring pixels (e.g., steps 103-120 in
[0506] setting at least two of the neighboring labels according to whether the current pixel is in any one of a first row, a first column and a last column(e.g., steps 106_1, 119,110 in
[0507] recording the center label to a label buffer;
[0508] wherein labels for marking pixels of the target binary image are first center labels, and then are second center labels, and are the first center labels again after the labels are the second center labels (e.g., pixel (R1, C1) is marked by 1 in the step 2, and then pixel (R1, C6) is marked by 2 in the step 6, and the pixel (R3, C6) is marked by 1 again in the step 22 [Same as the first comment at page 3 where we do not quite understand the first center labels and second center labels. Besides, the example for step 21 mentioned above, pixel (R2, C7) is actually 0, and (R2, C8)=1. Are these typo?].
[0509] The CCA method can further comprises at least one of following steps:
[0510] Set the center label to a new value if all of the neighboring labels are 0 (e.g., steps 122, 123 in
[0511] Set the center label to the new value plus 1, if all of the neighboring labels are 0 again in a process of a next pixel (e.g., steps 123 in
[0512] Set the center label to be a corresponding one of the neighboring labels if the corresponding one of the neighboring labels is larger than 0 (e.g., steps 126-129 in
[0513] Limit the center label to be lower than a maximum label threshold (e.g., steps 124, 125 in
[0514] Set the center label according to whether collision of used labels occurs (e.g., step 133 in
[0515] center label is set to a minimum one of specific ones of the neighboring labels when the collision occurs(e.g., step 134 in
[0516] Replace the center labels recorded in the label buffer with other values according to whether collision of used labels occurs (e.g., steps 135, 136 in
[0517] At least maximum one of specific ones of the neighboring labels is set to a minimum one of specific ones of the neighboring labels when the collision occurs (e.g., step 135 in
[0518] Set the center label to a new value if all of the neighboring labels are 0.
[0519] The center label which is recorded in the label buffer and has a value of the new value minus one, is replaced by a maximum one of the center labels of specific ones of the neighboring labels when the collision of used labels occurs (e.g., step 136 in
[0520] Besides the above-mentioned steps for computing the center label Lj, the CCA method can further comprise a step of recording numbers respectively for different center labels to compute a size of an image with a specific binary value in the target binary image (e.g, the Feature Table (Area) in
[0521] Also, the CCA method can further comprise a step of recording centroid reference values for different center labels; computing a centroid of an image with a specific binary value according to the centroid reference values in the target binary image. (e.g, the Feature Table (Centroid) in
[0522] Additionally, the CCA method can further comprise a step of recording bounding reference values for different center labels; computing a bounding box of an image with a specific binary value according to the bounding reference values in the target binary image. Such step can be implemented by computing bounding information related with a minimum one of specific ones of the neighboring labels, a maximum one of specific ones of the neighboring labels, and a new label, to compute the bounding box (e.g., step 139 in
[0523] The above-mentioned rules and steps can be applied for other label patterns and target binary image.
[0524] Step 1101
[0525] Start.
[0526] Step 1102
[0527] Set
[0528] new_label=1
[0529] num_blob=0
[0530] Step 1103
[0531] Set
[0532] P=a pixel value of the first pixel
[0533] Step 1104
[0534] Set Collision=0
[0535] Step 1105
[0536] Determine if P=0.
[0537] Step 1106
[0538] Set Lj=0
[0539] Step 1107
[0540] Determine if a current pixel is in a first row.
[0541] Step 1108
[0542] Set Lb=0
[0543] Step 1109
[0544] Set Lb=Top label.
[0545] Step 1110
[0546] Determine if the current pixel is in a first column
[0547] Step 1111
[0548] Set Ld=0
[0549] Step 1112
[0550] Set Ld=Left Label
[0551] FIG.12 comprises following steps, which follow the steps illustrated in FIG.11:
[0552] Step 1113
[0553] Determine if Lb=0 and Ld=0.
[0554] Step 1114
[0555] Set
[0556] num_blob=num_blob+1
[0557] Lj=new label
[0558] new_label=num_label+1
[0559] Step 1115
[0560] Determine if the new label (the new label set in step 1114) is larger than a maximum label.
[0561] Step 1116
[0562] Set the new label to be a maximum label stored in the label buffer.
[0563] Step 1117
[0564] Determine if Lb>0 and Ld=0.
[0565] Step 1118
[0566] Set Lj=Lb
[0567] Step 1119
[0568] Determine if Lb=0 and Ld>0.
[0569] Step 1120
[0570] Set Lj=Ld
[0571] Step 1121
[0572] Determine if Lb=Ld.
[0573] Step 1118
[0574] Set Lj=Lb
[0575] Step 1123
[0576] Set
[0577] Collision=1
[0578] Lmin=min(Lb, Ld)
[0579] Lmax=max(Lb, Ld)
[0580] Step 1124
[0581] Determine if Collision=1.
[0582] Step 1125
[0583] Set
[0584] FeatSize[Lj]=FeatSize[Lj]+1
[0585] Step 1126
[0586] Set Lj to Lmin
[0587] Step 1127
[0588] Replace all Lmax in the label buffer to Lmin.
[0589] Step 1128
[0590] Replace all (new_label-1) in the label buffer with Lmax.
[0591] Step 1129
[0592] Set Featsize [Lmin]=FeatSize[Lmin]+FeatSize[Lmax]+1
[0593] Set Featsize [Lmax]=FeatSize [new_label-1]
[0594] Set FeatSize [new_label-1]=0
[0595] Step 1130
[0596] Set
[0597] FeatCent [Lmin]=FeatCent[Lmin]+FeatCent[Lmax]+[row, col]
[0598] [FIG.13: Should be FeatCent instead of FeatCen]
[0599] FeatCent [Lmax]=FeatCent [new_label-1]
[0600] FeatCent [new label-1]=0
[0601] Step 1131
[0602] Set
[0603] FeatBboxLeft[Lmin]=
[0604] min(FeatBboxLeft[Lmin], FeatBboxLeft[Lmax], col)
[0605] FeatBboxRight[Lmin]=
[0606] max(FeatBboxRight[Lmin], FeatBboxRight [Lmax], col)
[0607] FeatBboxTop[Lmin]=
[0608] min(FeatBboxTop[Lmin], FeatBboxTop[Lmax], row)
[0609] FeatBboxBottom[Lmin]=
[0610] min(FeatBboxBottom[Lmin], FeatBboxBottom[Lmax], row)
[0611] FeatBboxLeft[Lmax]=FeatBboxLeft[new_label-1]
[0612] FeatBboxRight[Lmax]=FeatBboxRight[new_label-1]
[0613] FeatBboxTop[Lmax]=FeatBboxTop[new_label-1]
[0614] FeatBboxBottom[Lmax]=FeatBboxBottom[new_label-1]
[0615] FeatBboxLeft[new_label-1]=0
[0616] FeatBboxRight[new_label-1]=0
[0617] FeatBboxTop[new_label-1]=0
[0618] FeatBboxBottom[new_label-1]=0
[0619] [
[0620] Step 1132
[0621] Set
[0622] FeatCent[Lj]=FeatCent[Lj]+[row, col]
[0623] Step 1133
[0624] Determine if FeatSize[Lj] is 1.
[0625] [
[0626] Step 1134
[0627] Set
[0628] FeatBboxLeft[Lj]=col
[0629] FeatBboxRight[Lj]=col
[0630] FeatBboxTop[Lj]=row
[0631] FeatBboxBottom[Lj]=row
[0632] [FIG.13: Should be 1134 instead of 1132]
[0633] Step 1135
[0634] Set
[0635] FeatBboxLeft[Lj]=min(FeatBboxLeft[Lj],col)
[0636] FeatBboxRight[Lj]=max(FeatBboxRight[Lj],col)
[0637] FeatBboxTop[Lj]=min(FeatBboxTop[Lj],row)
[0638] FeatBboxBottom[Lj]=max(FeatBboxBottom[Lj],row)
[0639] Step 1136
[0640] num_blob=num_blob-1
[0641] new_label=new_label-1
[0642] Step 1137
[0643] Record Lj to label buffer
[0644] Step 1138
[0645] Determine if the current pixel is the last pixel.
[0646] Step 1139
[0647] Set P=a pixel value of a next pixel, and goes back to the step 1104 to process next pixel. [
[0648] Step 1140
[0649] End
[0650] The meanings of all steps in
[0651]
[0652] The CCA method can be applied to an image sensor comprising a sensor array (e.g., a pixel array) and a processing circuit. In such case, the sensor array outputs a binary image, wherein the binary image has M*N pixels, M>2 and N>3, such as the binary image 1500 in
[0653] In view of above-mentioned embodiments, the label can be reused, and the label collision can be handled without increasing a size of the label buffer.
[0654] Those skilled in the art will readily observe that numerous modifications and alterations of the device and method may be made while retaining the teachings of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims.