Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions menus/Opencv/Segmentation/awatershed_plg.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*
from imagepy.core.engine import Filter
from sciapp.action import Filter
import numpy as np, cv2
from sciapp.object import image

class Plugin(Filter):
title = 'Active Watershed'
note = ['rgb', 'not_slice', 'auto_snap']
def run(self, ips, snap, img, para = None):
a, msk = cv2.connectedComponents(ips.get_msk().astype(np.uint8))
msk = cv2.watershed(img, msk)==-1
img //= 2
img[msk] = 255
title = 'Active Watershed'
note = ['rgb', 'req_roi', 'not_slice', 'auto_snap']

def run(self, ips, snap, img, para=None):
a, msk = cv2.connectedComponents(ips.mask('in').astype(np.uint8))
msk = cv2.watershed(ips.img, msk) == -1
ips.img //= 2
ips.img[msk] = 255