Commit b8babe87 authored by Sean Fitzgibbon's avatar Sean Fitzgibbon
Browse files

Added additional preprocessing to _img_props

parent 410f89aa
...@@ -25,12 +25,15 @@ from slider import util ...@@ -25,12 +25,15 @@ from slider import util
import glymur import glymur
from skimage.measure import regionprops, label from skimage.measure import regionprops, label
from skimage.color import rgb2gray from skimage.color import rgb2gray, rgb2hsv
from skimage import filters, transform from skimage import filters, transform, exposure
from matplotlib import patches from matplotlib import patches
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
DO_PLOTS = False
OUTDIR = None
def register_chart_to_slide(chart, slide, slide_res, out, boundary_key=None, config=None): def register_chart_to_slide(chart, slide, slide_res, out, boundary_key=None, config=None):
...@@ -50,10 +53,7 @@ def register_chart_to_slide(chart, slide, slide_res, out, boundary_key=None, con ...@@ -50,10 +53,7 @@ def register_chart_to_slide(chart, slide, slide_res, out, boundary_key=None, con
# set global variables required for summary plots # set global variables required for summary plots
plots = config["general"]["plots"] plots = config["general"]["plots"]
global DO_PLOTS
DO_PLOTS = plots DO_PLOTS = plots
global OUTDIR
OUTDIR = out OUTDIR = out
# create output dir # create output dir
...@@ -241,11 +241,15 @@ def _refine_edge_coord(img, img_res, edge_coords, normals): ...@@ -241,11 +241,15 @@ def _refine_edge_coord(img, img_res, edge_coords, normals):
def _img_props(img, img_resolution, verbose=False): def _img_props(img, img_resolution, verbose=False):
# convert to grayscale # # convert to grayscale
image = rgb2gray(img) # image = rgb2gray(img)
# find threshold for background # # find threshold for background
threshold_value = filters.threshold_otsu(image) # threshold_value = filters.threshold_otsu(image)
image = rgb2hsv(img)[..., -1]
image = exposure.equalize_hist(image)
threshold_value = filters.threshold_li(image)
if verbose: if verbose:
print(f"threshold={threshold_value}") print(f"threshold={threshold_value}")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment