Commit 86162d62 authored by aknecht2's avatar aknecht2

Fixed bgr -> gray bug for fluosv images.

parent ea29d649
......@@ -326,7 +326,7 @@ class Image(object):
Assumes that image is already binary.
"""
if self._isColor():
binary = cv2.inRange(self.image.copy(), np.array([1, 1, 1], np.uint8), np.array([255, 255, 255], np.uint8))
binary = cv2.inRange(self.image.copy(), np.array([0, 0, 1], np.uint8), np.array([255, 255, 255], np.uint8))
else:
binary = self.image.copy()
contours,hierarchy = cv2.findContours(binary, cv2.RETR_EXTERNAL, 2)
......@@ -341,7 +341,7 @@ class Image(object):
A helper function that draws all detected contours in the image onto the image.
"""
if self._isColor():
binary = cv2.inRange(self.image.copy(), np.array([1, 1, 1], np.uint8), np.array([255, 255, 255], np.uint8))
binary = cv2.inRange(self.image.copy(), np.array([0, 0, 1], np.uint8), np.array([255, 255, 255], np.uint8))
else:
binary = self.image.copy()
contours, hierarchy = cv2.findContours(binary, cv2.RETR_EXTERNAL, 2)
......@@ -1255,7 +1255,7 @@ class Image(object):
and central normalized moments are prefixed with 'nu'. This function
is a wrapper to the OpenCV function `moments <http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html#moments>`_.
"""
moments = cv2.moments(cv2.inRange(self.image, np.array([1, 1, 1], np.uint8), np.array([255, 255, 255], np.uint8)))
moments = cv2.moments(cv2.inRange(self.image, np.array([0, 0, 1], np.uint8), np.array([255, 255, 255], np.uint8)))
if self.conn:
for id in moments:
self._addColumn(id)
......@@ -1320,7 +1320,7 @@ class Image(object):
Returns the center and radius of the minimum enclosing circle of all
non-black pixels in the image. The point of this function
is not to threshold, so the contours are generated from
all the pixels that fall into the range [1, 1, 1], [255, 255, 255].
all the pixels that fall into the range [0, 0, 1], [255, 255, 255].
"""
circle = cv2.minEnclosingCircle(self._getMergedContour())
if self.conn:
......@@ -1339,7 +1339,7 @@ class Image(object):
Returns the area of the convex hull around all non black pixels in the image.
The point of this function is not to threshold, so the contours are generate from
all the pixels that fall into the range [1, 1, 1], [255, 255, 255]
all the pixels that fall into the range [0, 0, 1], [255, 255, 255]
"""
hull = cv2.contourArea(
cv2.approxPolyDP(
......@@ -1362,9 +1362,9 @@ class Image(object):
Returns the number of non-black pixels in the image. Creates
a temporary binary image to do this. The point of this function
is not to threshold, so the binary image is created by all
pixels that fall into the range [1, 1, 1], [255, 255, 255].
pixels that fall into the range [0, 0, 1], [255, 255, 255].
"""
pixelCount = cv2.countNonZero(cv2.inRange(self.image, np.array([1, 1, 1], np.uint8), np.array([255, 255, 255], np.uint8)))
pixelCount = cv2.countNonZero(cv2.inRange(self.image, np.array([0, 0, 1], np.uint8), np.array([255, 255, 255], np.uint8)))
if self.conn:
self._addColumn("pixels")
self.conn.execute("update images set pixels=? where pegasusid=?", (pixelCount, self.dbid))
......
Markdown is supported
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