#
# What to show in diagnostic output images
-Show_edges = True
+Show_edges = False
+Show_dark_stain = False
Show_stain = False
Show_infection = False
#
# gaussian_blur(image, a) - b * gaussian_blur(image, c)
-Enhance_a = 1.0
-Enhance_b = 0.75
-Enhance_c = 20.0
+Enhance_a = 2.0 # base: 1.0, 50x: 2.0, 100x: 4.0
+Enhance_b = 0.75 # base: 0.75
+Enhance_c = 40.0 # base: 20.0, 50x: 40.0, 100x: 80.0
# Larger = enlarge background area, smaller = enlarge foreground area
Background_weight = 0.915 #&median
# Cell size parameters
# Size of cells, for Hough transform
-Hough_min_radius = 5
-Hough_max_radius = 32 # 20
+Hough_min_radius = 20 # 50x: 20, 100x: 40
+Hough_max_radius = 45 # 50x: 45, 100x: 90
# Portion of cell used for classification as infected/weird
# (may be abutting an infected cell, so be cautious)
Cell_inside_radius = 0.9
# Do not allow another cell center to be detected within this radius
-Cell_suppression_radius = 1.05 # 1.25
+Cell_suppression_radius = 0.8 # 1.05
# =======================
Max_dark_stain_proportion = 0.728
# Minimum/maximum radius (as determined by Hough transform)
-Min_cell_radius = 11 # 9
-Max_cell_radius = 32 # 20
+Min_cell_radius = 25 # Base: 9, 50x: 25, 100x: 50
+Max_cell_radius = 40 # Base: 20, 50x: 40, 100x: 80
# Proportion of radius that center of mass can be away from Hough determined center
Max_offcenter = 0.5
"""
output = numpy.empty(array.shape, array.dtype)
for i in xrange(array.shape[2]):
- ndimage.gaussian_filter(array[:,:,i],amount,output=output[:,:,i])
+ ndimage.gaussian_filter(array[:,:,i],amount, output=output[:,:,i])
return output
# Denoise/unsharp mask
# [GB] (Concerne les trois channels RGB).
a_enhanced = gaussian_blur(a, Enhance_a) - Enhance_b * gaussian_blur(a, Enhance_c)
+
# Split into foreground and background using k-medians
status('fg/bg')
(a_enhanced[:,:,1] < color_fg[1]) & # [GB] Green channel
fg
)
-
-
+
fg_float = fg.astype('float64')
green = a[:,:,1] * fg_float
green_local_bg = ndimage.gaussian_filter(green, Stain_bg_blur)
a_output[stain,2] += 128
if Show_infection:
a_output[infection,0] += 128
+ if Show_dark_stain:
+ a_output[infection,0] += 128
#a_output[stain, 1] += 128
# (more blurring allows greater deviation from circularity)
# (if you alter this you will also need to alter thresh, below)
- hough = ndimage.gaussian_filter(hough, 1.0)
+ hough = ndimage.gaussian_filter(hough, 1.5) # 1.0
return hough
#a_output[:,:,:] = hough[:,:,None]*20
# Find and classify peaks in Hough transform image
- thresh = 1.5 #Hmm
+ thresh = 0.8 #Hmm 1.5
candidates = [ ]
for y in xrange(height):
for x in xrange(width):
if hough[y, x] > thresh:
candidates.append((hough[y,x], y, x))
candidates.sort(reverse = True)
- hough
-
+
status('classify')
i2 = Image.fromarray(a_output.astype('uint8'))
i2.save(filename_out)
+ thresh_output = numpy.clip(fg, 0, 255)
+ i3 = Image.fromarray(thresh_output.astype('uint8'))
+ i3.save(filename_out + " - thresholded.tiff")
+
def read_ac(filename):