Skip to content

Commit

Permalink
edits with Chee
Browse files Browse the repository at this point in the history
  • Loading branch information
boris-kz committed Feb 28, 2025
1 parent 475b96e commit 4a3ac0d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 33 deletions.
25 changes: 11 additions & 14 deletions frame_2D_alg/agg_recursion.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,22 +311,19 @@ def agg_H_par(focus): # draft parallel level-updating pipeline

frame.aggH = list(H) # convert back to list

def agg_H_seq(focus, image, _nestt=(1,0), rave_=[]): # recursive level-forming pipeline, called from cluster_C_
# draft:
global ave, ave_L, icoef, max_dist # add derTT aves
if rave_:
ave_ = np.array([ave, ave_L, max_dist, icoef]) # mw_, dw_
ave, ave_L, max_dist, icoef = ave_ * rave_
else:
rave_ = np.append(np.ones(4), np.ones(4), np.ones(4))
# weight per ave?
frame = frame_blobs_root(focus, rave_2FB(rave_))
intra_blob_root(frame, rave_2IB(rave_)) # not sure
vectorize_root(frame, rave_2VR(rave_))
def agg_H_seq(focus, image, _nestt=(1,0), _rM=0, _rV_t=[]): # recursive level-forming pipeline, called from cluster_C_

global ave, ave_L, icoef, max_dist, ave_w, ave_L_w, icoef_w, max_dist_w # add weight per global
if _rM:
ave *= ave_w*_rM; ave_L *= ave_L_w*_rM; icoef *= icoef_w*_rM; max_dist *= max_dist_w*_rM
# fb _rM only
frame = frame_blobs_root(focus, _rM)
intra_blob_root(frame, _rM) # not sure
vectorize_root(frame, _rM, _rV_t)
if not frame.nnest:
return frame
comb_altG_(frame.node_[-1].node_, ave*2) # PP graphs in frame.node_[2]
# feedforward agg+
# forward agg+:
cluster_C_(frame, rc=1) # ave *= recursion count
rM,rD = 1,1 # sum derTT coefs: m_,d_ [M,D,n,o I,G,A,L] / Et, baseT, dimension
rV_t = np.ones((2,8)) # d value is borrowed from corresponding ms in proportion to d mag, both scaled by fb
Expand All @@ -350,7 +347,7 @@ def agg_H_seq(focus, image, _nestt=(1,0), rave_=[]): # recursive level-forming
y = y+dy; x = x+dx; Y = Y+dy; X = X+dx # alter focus shape, also focus size: +/m-, res decay?
if y > 0 and x > 0 and Y < image.shape[0] and X < image.shape[1]: # focus is inside the image
# rerun agg+ with new bottom-level focus, aves:
agg_H_seq(image[y:Y,x:X], image, (frame.nnest,frame.lnest), rave_=rV_t)
agg_H_seq(image[y:Y,x:X], image, (frame.nnest,frame.lnest), rM, rV_t)

return frame

Expand Down
8 changes: 4 additions & 4 deletions frame_2D_alg/comp_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ def comp_latuple(_latuple, latuple, _n,n): # 0der params, add dir?
I, G, M, D, L, (Dy, Dx) = latuple
rn = _n / n

I*=rn; dI = _I - I; mI = ave_dI -dI / max(_I,I) # vI = mI - ave)
G*=rn; dG = _G - G; mG = min(_G, G) / max(_G,G) # vG = mG - ave_mG
M*=rn; dM = _M - M; mM = min(_M, M) / max(_M,M) # vM = mM - ave_mM
D*=rn; dD = _D - D; mD = min(_D, D) / max(_D,D) # vD = mD - ave_mD
I*=rn; dI = _I - I; mI = ave_dI -dI / max(_I,I, 1e-7) # vI = mI - ave
G*=rn; dG = _G - G; mG = min(_G, G) / max(_G,G, 1e-7) # vG = mG - ave_mG
M*=rn; dM = _M - M; mM = min(_M, M) / max(_M,M, 1e-7) # vM = mM - ave_mM
D*=rn; dD = _D - D; mD = min(_D, D) / max(_D,D, 1e-7) # vD = mD - ave_mD
L*=rn; dL = _L - L; mL = min(_L, L) / max(_L,L) # vL = mL - ave_mL
mA, dA = comp_angle((_Dy,_Dx),(Dy,Dx)) # vA = mA - ave_mA, normalized

Expand Down
7 changes: 3 additions & 4 deletions frame_2D_alg/slice_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def slice_edge(edge, _fb_={}, fb_={}):
while yx_:
yx = yx_.pop(); axis = axisd[yx] # get max of g maxes
P = form_P(CP(yx, axis), edge)
if P: edge.P_ += [P]
edge.P_ += [P]
yx_ = [yx for yx in yx_ if yx not in edge.rootd] # remove merged maxes if any
edge.P_.sort(key=lambda P: P.yx, reverse=True)
trace_P_adjacency(edge)
Expand Down Expand Up @@ -106,9 +106,8 @@ def form_P(P, edge):

P.yx = tuple(np.mean([P.yx_[0], P.yx_[-1]], axis=0)) # new center
P.latuple = new_latuple(I,G, M,D, L, [Dy, Dx])
if len(P.dert_)>1: # skip single dert's P
edge.rootd[iy,ix] = P
return P
edge.rootd[iy,ix] = P
return P

def trace_P_adjacency(edge): # fill and trace across slices

Expand Down
22 changes: 11 additions & 11 deletions frame_2D_alg/vect_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,23 +158,23 @@ def __init__(l, **kwargs):
# add med, rimt, extH in der+
def __bool__(l): return bool(l.nodet)

def vectorize_root(frame, rave_=[]): # init for agg+:
def vectorize_root(frame, _rM=0, _rV_t=[]): # init for agg+:
# draft:
global ave, ave_d, ave_rn, ave_ro, ave_G, ave_L, max_dist, icoef, med_cost, ave_dI, mw_, dw_
if rave_:
ave_ = np.array([ave, ave_d, ave_rn, ave_ro, ave_G, ave_L, max_dist, icoef, med_cost, ave_dI, mw_, dw_])
ave, ave_d, ave_rn, ave_ro, ave_G, ave_L, max_dist, icoef, med_cost, ave_dI, mw_, dw_ = ave_ * rave_
else:
rave_ = np.append(np.ones(10), np.ones(10), np.ones(10)) # weight per ave?
if _rM:
ave, ave_d, ave_rn, ave_ro, ave_G, ave_L, max_dist, icoef, med_cost, ave_dI = (
np.array([ave, ave_d, ave_rn, ave_ro, ave_G, ave_L, max_dist, icoef, med_cost, ave_dI]) * mw_ * _rM)
# also derTT aves * _rV_t?
# else: rave_ = np.append(np.ones(10), np.ones(10), np.ones(10)) # weight per ave?
blob_ = unpack_blob_(frame)
frame2G(frame, derH=[CLay(root=frame)], node_=[blob_], root=None)
edge_ = [] # cluster, unpack
for blob in blob_:
if not blob.sign and blob.G > ave_G * blob.root.olp:
# convert rave_ to slice_edge coefs:
edge = slice_edge(blob, rave_2SE(rave_))
# slice_edge globals * weights * _rM:
edge = slice_edge(blob, _rM)
if edge.G * (len(edge.P_)-1) > ave: # eval PP
comp_slice(edge, rave_2CS(rave_))
comp_slice(edge, _rM)
if edge.Et[0] * (len(edge.node_)-1)*(edge.rng+1) > ave:
G_ = [PP2G(PP)for PP in edge.node_ if PP[-1][0] > ave] # Et, no altGs
if len(G_) > ave_L: # no comp node_,link_,PPd_
Expand Down Expand Up @@ -576,8 +576,8 @@ def PP2G(PP):

baseT = np.array((*latuple[:2], *latuple[-1])) # I,G,Dy,Dx
[mI,mG,mA,mM,mD,mL], [dI,dG,dA,dM,dD,dL] = vert
derTT = np.array([np.array([mM,mD,mL,1,mI,mG,*mA,mL]), np.array([dM,dD,dL,1,dI,dG,*dA,dL])])
y,x,Y,X = box; dy,dx = Y-y,X-x # A = (dy,dx); L = np.hypot(dy,dx)
derTT = np.array([np.array([mM,mD,mL,0,mI,mG,mA,mL]), np.array([dM,dD,dL,0,dI,dG,dA,dL])])
y,x,Y,X = box; dy,dx = Y-y,X-x # A = (dy,dx); L = np.hypot(dy,dx)
G = CG(root=root, fd=0, Et=Et, node_=P_, link_=[], baseT=baseT, derTT=derTT, box=box, yx=yx, aRad=np.hypot(dy/2, dx/2),
derH=[[CLay(node_=P_,link_=link_, derTT=deepcopy(derTT)), CLay()]]) # empty dfork
return G
Expand Down

0 comments on commit 4a3ac0d

Please sign in to comment.