1 | initial version |
the "posterized" image output is only a visualization for humans, for a program rather use the index version.
each "blob" is numbered, and has its own index, you can access the corresponding pixels from python like:
mask = img[img==17] # True/False mask for blob 17, same size as original image
if you really need contours:
mask = np.astype(np.uint8) # bool -> binary image
cnt,hier = cv2.findContours(mask, .....)
2 | No.2 Revision |
the "posterized" image output is only a visualization for humans, for a program rather use the index version.
each "blob" is numbered, and has its own index, you can access the corresponding pixels from python like:
mask = img[img==17] cv2.compare(res, 17, cv2.CMP_EQ) # True/False 0/1 mask for blob 17, same size as original input image
if you really need contours:
mask = np.astype(np.uint8) # bool -> binary image
cnt,hier = cv2.findContours(mask, .....)
3 | No.3 Revision |
the "posterized" image output is only a visualization for humans, for a program rather use the index version.
im = cv2.imread("some.png")
h = cv2.hfs.HfsSegment_create(im.shape[0],im.shape[1])
res = h.performSegmentCpu(im, False) # False -> indexed
each "blob" is numbered, and has its own index, you can access the corresponding pixels from python like:
mask = cv2.compare(res, 17, cv2.CMP_EQ) # 0/1 mask for blob 17, same size as input image
if you really need contours:
cnt,hier = cv2.findContours(mask, .....)
4 | No.4 Revision |
the "posterized" image output is only a visualization for humans, for a program rather use the index version.
im = cv2.imread("some.png")
h = cv2.hfs.HfsSegment_create(im.shape[0],im.shape[1])
res = h.performSegmentCpu(im, False) # False -> indexed
each "blob" is numbered, and has its own index, you can access the corresponding pixels make a binary mask from it in python like:
mask = cv2.compare(res, 17, cv2.CMP_EQ) # 0/1 mask for blob 17, same size as input image
if you really need contours:
cnt,hier = cv2.findContours(mask, .....)
5 | No.5 Revision |
the "posterized" image output is only a visualization for humans, for a program rather use the index version.
im = cv2.imread("some.png")
h = cv2.hfs.HfsSegment_create(im.shape[0],im.shape[1])
res = h.performSegmentCpu(im, False) # False -> indexed
indexed (16U)
each "blob" is numbered, and has its own index, you can make a binary mask from it in python like:
mask = cv2.compare(res, 17, cv2.CMP_EQ) # 0/1 mask for blob 17, same size as input image
if you really need contours:
cnt,hier = cv2.findContours(mask, .....)