-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,6 @@ | |
|
||
class CderBlob(ClusterStructure): | ||
|
||
blob = object # not needed, common for all derBlobs in derBlob_? | ||
_blob = object | ||
mB = int | ||
dB = int | ||
|
@@ -20,16 +19,13 @@ class CderBlob(ClusterStructure): | |
mG = int | ||
dM = int | ||
mM = int | ||
# DerBlob only, do not accumulate: | ||
neg_mB = int | ||
distance = int | ||
|
||
class CBblob(ClusterStructure): | ||
|
||
DerBlob = object | ||
blob_ = list | ||
|
||
ave_mB = -20000 | ||
ave_mB = 20000 # ave can't be negative | ||
ave_rM = .7 # average relative match at rL=1: rate of ave_mB decay with relative distance, due to correlation between proximity and similarity | ||
|
||
|
||
|
@@ -40,8 +36,9 @@ def cross_comp_blobs(frame): | |
blob_ = frame.blob_ | ||
|
||
for blob in blob_: # each blob forms derBlob per compared adj_blob and accumulates adj_blobs'derBlobs: | ||
comp_blob_recursive(blob, blob.adj_blobs[0], derBlob_=[], derBlob_id_=[]) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
# derBlob_ and derBlob_id_ are local and frame-wide | ||
blob.DerBlob = CderBlob() | ||
comp_blob_recursive(blob, blob.adj_blobs[0], comped_id_=[blob.id]) | ||
|
||
bblob_ = form_bblob_(blob_) # form blobs of blobs, connected by mutual match | ||
|
||
|
@@ -50,29 +47,38 @@ def cross_comp_blobs(frame): | |
return bblob_ | ||
|
||
|
||
def comp_blob_recursive(blob, adj_blob_, comped_id_): | ||
def comp_blob_recursive(blob, adj_blob_, derBlob_, derBlob_id_): | ||
''' | ||
called by cross_comp_blob to recursively compare blob to adj_blobs in incremental layers of adjacency | ||
''' | ||
for adj_blob in adj_blob_: | ||
if adj_blob.id in comped_id_: # this is ids of blobs compared to immediate adjacents? | ||
# pseudo for assign checked id' derBlob as current derBlob: | ||
derBlob = @ adj_blob.id | ||
accum_derBlob(blob, derBlob) | ||
else: | ||
derBlob = comp_blob(blob, adj_blob) # compare blob and adjacent blob | ||
accum_derBlob(blob, derBlob) # from all compared blobs, regardless of mB sign | ||
comped_id_.append(adj_blob.id) | ||
|
||
if derBlob.mB > 0: # replace blob with adj_blob for continuing adjacency search: | ||
adj_blob.DerBlob = CderBlob() | ||
comp_blob_recursive(adj_blob, adj_blob.adj_blobs[0], comped_id_) | ||
else: | ||
blob.DerBlob.neg_mB += derBlob.mB # mB accumulated over comparison scope | ||
blob.DerBlob.distance += np.sqrt(adj_blob.A) | ||
|
||
if blob.Dert.M + blob.DerBlob.neg_mB > ave_mB: # negative mB, extend blob comparison to adjacents of adjacent, depth-first | ||
comp_blob_recursive(blob, adj_blob.adj_blobs[0], comped_id_) | ||
derBlob_id = adj_blob.id * blob.id # unique comparand_pair identifier, frame-wide, same for derBlob_? | ||
This comment has been minimized.
Sorry, something went wrong.
kwcckw
|
||
fnew = 1 # new comparand pair | ||
|
||
for i, id in enumerate(derBlob_id_): # is there a shortcut for finding index of a known value, this could be very slow? | ||
This comment has been minimized.
Sorry, something went wrong.
kwcckw
|
||
if id==derBlob_id: | ||
derBlob = derBlob_[i] | ||
accum_derBlob(blob, derBlob) # also adj_blob.rdn += 1: redundancy coeff? | ||
This comment has been minimized.
Sorry, something went wrong.
kwcckw
|
||
fnew=0 | ||
break | ||
if fnew: | ||
if adj_blob is not blob: | ||
derBlob = comp_blob(blob, adj_blob) # compare blob and adjacent blob | ||
accum_derBlob(blob, derBlob) # from all compared blobs, regardless of mB sign | ||
derBlob_id_.append(adj_blob.id * blob.id) # unique comparand_pair identifier | ||
derBlob_.append(derBlob) # also frame-wide | ||
|
||
if derBlob.mB > 0: | ||
# replace blob with adj_blob for continuing adjacency search: | ||
if not isinstance(adj_blob.DerBlob, CderBlob): # do we really need this? | ||
This comment has been minimized.
Sorry, something went wrong.
kwcckw
|
||
adj_blob.DerBlob = CderBlob() | ||
comp_blob_recursive(adj_blob, adj_blob.adj_blobs[0], derBlob_, derBlob_id_) | ||
|
||
elif blob.Dert.M + blob.neg_mB+ derBlob.mB > ave_mB: # neg mB but positive comb M, | ||
# extend blob comparison to adjacents of adjacent, depth-first | ||
blob.neg_mB += derBlob.mB # mB and distance are accumulated over comparison scope | ||
blob.distance += np.sqrt(adj_blob.A) | ||
comp_blob_recursive(blob, adj_blob.adj_blobs[0], derBlob_, derBlob_id_) | ||
|
||
|
||
def comp_blob(blob, _blob): | ||
|
@@ -91,11 +97,11 @@ def comp_blob(blob, _blob): | |
dM = _M - M | ||
mM = min(_M, M) | ||
|
||
mB = mI + mA + mG + mM - ave_mB * (ave_rM ** ((1+blob.DerBlob.distance) / np.sqrt(A))) | ||
mB = mI + mA + mG + mM - ave_mB * (ave_rM ** ((1+blob.distance) / np.sqrt(A))) | ||
# deviation from average blob match at current distance | ||
dB = dI + dA + dG + dM | ||
|
||
derBlob = CderBlob(blob=blob, _blob=_blob, mB=mB, dB=dB) # blob is core node, _blob is adjacent blob | ||
derBlob = CderBlob(_blob=_blob, mB=mB, dB=dB) # blob is core node, _blob is adjacent blob | ||
|
||
if _blob.fsliced and blob.fsliced: | ||
pass | ||
|
@@ -127,17 +133,13 @@ def form_bblob_recursive(bblob_, bblob, checked_ids): | |
for blob in bblob.blob_: # search blob' derBlob's blobs to get potential border clustering blob | ||
if (blob.DerBlob.mB > 0) and (blob.id not in checked_ids): # positive mB | ||
for derBlob in blob.derBlob_: | ||
# if derBlob.blob is in bblob.blob_, but derBlob._blob is not in bblob_blob_ | ||
# if blob is in bblob.blob_, but derBlob._blob is not in bblob_blob_ | ||
# so if sum of derBlob._blob's mB with blob's mB > 0 , pack the derBlob._blob into bblob.blob_ | ||
if (derBlob.blob in bblob.blob_) and (derBlob._blob.DerBlob.mB + blob.DerBlob.mB >0) and (derBlob._blob not in bblob.blob_): | ||
merge_blob = derBlob._blob | ||
fsearch = 1 | ||
if (derBlob._blob in bblob.blob_) and (derBlob._blob.DerBlob.mB + blob.DerBlob.mB >0) and (derBlob.blob not in bblob.blob_): | ||
merge_blob = derBlob.blob | ||
fsearch = 1 | ||
if fsearch: | ||
accum_bblob(bblob, merge_blob) | ||
if (derBlob._blob not in bblob.blob_) and (derBlob._blob.DerBlob.mB + blob.DerBlob.mB >0): | ||
accum_bblob(bblob, derBlob._blob) | ||
checked_ids.append(blob.id) | ||
fsearch = 1 | ||
|
||
if fsearch: | ||
form_bblob_recursive(bblob_, bblob, checked_ids) | ||
|
||
|
why we apply comp_blob_recursive first before initialize the blob.DerBlob? Wouldn't this wipe out the accumulated blob.DerBlob from the comp_blob_recursive if we initialize it afterwards?