Showing 123 of 380 total issues
Function fill_labeled_holes
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def fill_labeled_holes(labels, mask=None, size_fn=None):
"""Fill all background pixels that are holes inside the foreground
A pixel is a hole inside a foreground object if
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function table_lookup
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def table_lookup(image, table, border_value, iterations=None):
"""Perform a morphological transform on an image, directed by its neighbors
image - a binary image
table - a 512-element table giving the transform of each pixel given
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function euler_number
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
def euler_number(labels, indexes=None):
"""Calculate the Euler number of each label
labels - a label matrix
indexes - the indexes of the labels to measure or None to
Function feret_diameter
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
def feret_diameter(chulls, counts, indexes):
"""Return the minimum and maximum Feret diameter for each object
This function takes the convex hull data, as generated by convex_hull
and returns the minimum and maximum Feret diameter for each convex hull.
Function get_mog_threshold
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def get_mog_threshold(image, mask=None, object_fraction=0.2):
"""Compute a background using a mixture of gaussians
This function finds a suitable
threshold for the input image Block. It assumes that the pixels in the
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function convex_hull_transform
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def convex_hull_transform(
image, levels=256, mask=None, chunksize=CONVEX_HULL_CHUNKSIZE, pass_cutoff=16
):
"""Perform the convex hull transform of this image
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function draw_line
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def draw_line(labels, pt0, pt1, value=1):
"""Draw a line between two points
pt0, pt1 are in i,j format which is the reverse of x,y format
Uses the Bresenham algorithm
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function stretch
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def stretch(image, mask=None):
"""Normalize an image to make the minimum zero and maximum one
image - pixel data to be normalized
mask - optional mask of relevant pixels. None = don't mask
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function prcntiles
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def prcntiles(x, percents):
"""Equivalent to matlab prctile(x,p), uses linear interpolation."""
x = np.array(x).flatten()
listx = np.sort(x)
xpcts = []
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Consider simplifying this complex logical expression. Open
value
if (
fn(i, 0, 0, 0)
and fn(i, 1, 0, 1)
and fn(i, 2, 0, 2)
Function convex_hull_ijv
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def convex_hull_ijv(pixel_labels, indexes, fast=True):
"""Return the convex hull for each label using an ijv labeling
pixel_labels: the labeling of the pixels in i,j,v form where
i & j are the coordinates of a pixel and v is
Function get_otsu_threshold
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def get_otsu_threshold(
image,
mask=None,
two_class_otsu=True,
use_weighted_variance=True,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function color_labels
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def color_labels(labels, distance_transform=False):
"""Color a labels matrix so that no adjacent labels have the same color
distance_transform - if true, distance transform the labels to find out
which objects are closest to each other.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function get_outline_pts
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_outline_pts(labels, idxs):
"""Get the outline points of objects in clockwise order
Given a labels matrix of contiguously-labeled objects, trace
the exteriors of those objects to get the points of the outline
Function lapjv
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def lapjv(i, j, costs, wants_dual_variables=False, augmenting_row_reductions=2):
"""Sparse linear assignment solution using Jonker-Volgenant algorithm
i,j - similarly-sized vectors that pair the object at index i[n] with
the object at index j[j]
Function associate_by_distance
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def associate_by_distance(labels_a, labels_b, distance):
"""Find the objects that are within a given distance of each other
Given two labels matrices and a distance, find pairs of objects that
are within the given distance of each other where the distance is
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function automode
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def automode(data):
"""Tries to guess if the image contains dark objects on a bright background (1)
or if the image contains bright objects on a dark background (-1),
or if it contains both dark and bright objects on a gray background (0)."""
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function bilateral_filter
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def bilateral_filter(
image, mask, sigma_spatial, sigma_range, sampling_spatial=None, sampling_range=None
):
"""Bilateral filter of an image
Function calculate_convex_hull_areas
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def calculate_convex_hull_areas(labels, indexes=None):
"""Calulculate the area of the convex hull of each labeled object
labels - a label matrix
indexes - None: calculate convex hull area over entire image
Function pairwise_permutations
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def pairwise_permutations(i, j):
"""Return all permutations of a set of groups
This routine takes two vectors:
i - the label of each group