Skip to content

Commit

Permalink
first commit for border properties
Browse files Browse the repository at this point in the history
  • Loading branch information
jcopperm committed Nov 8, 2024
1 parent 793b454 commit 0a770f0
Show file tree
Hide file tree
Showing 5 changed files with 315 additions and 15 deletions.
4 changes: 2 additions & 2 deletions celltraj/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,13 +847,13 @@ def get_contact_labels(labels0,radius=10):
labels_inv=-1*labels_inv
contact_msk=get_contact_boundaries(labels0,boundary_only=True,radius=radius)
contact_labels=np.zeros_like(labels0)
for i in np.unique(labels0[labels0>0]):
for i in np.flip(np.unique(labels0[labels0>0])):
indi=np.where(np.logical_and(labels0==i,contact_msk))
jset1=np.unique(labels[indi])
jset2=np.unique(labels_inv[indi])
jset=np.unique(np.concatenate((jset1,jset2)))
jset=np.setdiff1d(jset,[i])
for j in jset:
for j in np.flip(jset):
if labels0.ndim==2:
contact_labels[indi[0][labels[indi]==j],indi[1][labels[indi]==j]]=j
contact_labels[indi[0][labels_inv[indi]==j],indi[1][labels_inv[indi]==j]]=j
Expand Down
4 changes: 4 additions & 0 deletions celltraj/imageprep.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ def znorm(img):
img=(img-np.nanmean(img))/np.nanstd(img)
return img

def rescale_to_int(img,maxint=2**16-1,dtype=np.uint16):
img=maxint*((img-np.min(img))/np.max(img-np.min(img)))
return img.astype(dtype)

def histogram_stretch(img,lp=1,hp=99):
"""
Performs histogram stretching on an input array or image to enhance the contrast by scaling the pixel
Expand Down
Loading

0 comments on commit 0a770f0

Please sign in to comment.