Deep Watershed Transform for Instance Segmentation CVPR2017 https://github.com/min2209/dwt 本文将传统的 watershed transform 分割算法 结合 CNN网络 实现 物体分割 ? 这样我们就可以将地形图分割为若干区域,这里每个区域我们称之为 catchment basins,我们建造的水坝 barriers or watershed lines 表示两物体的边界线。 ? 4 Deep Watershed Tranform 这里我们希望使用 CNN网络来学习预测 一个 energy landscape,其每个 basin 对应一个物体,如上图的下半部分所示。 Watershed Transform Network (WTN) 基于分水岭能量图的下降方向图,我们来 predict a modified watershed transform energy
Opencv 中 watershed函数原型: void watershed( InputArray image, InputOutputArray markers ); 第一个参数 image,必须是一个 而分水岭方法完成之后并不会直接生成分割后的图像,还需要进一步的显示处理,如此看来,只有两个参数的watershed其实并不简单。 下边通过图示来看一下watershed函数的第二个参数markers在算法执行前后发生了什么变化。 总的概括一下watershed图像自动分割的实现步骤: 1. 图像灰度化、滤波、Canny边缘检测 2. 查找轮廓,并且把轮廓信息按照不同的编号绘制到watershed的第二个入参merkers上,相当于标记注水点。 3. watershed分水岭运算 4.
参考链接: Python中的numpy.isscalar “”“ watershed.py-分水岭算法 该模块实现了分水岭算法,可将像素分配到标记的盆地中。 False): """Find watershed basins in `image` flooded from given `markers`. Higher values result in more regularly-shaped watershed basins. watershed_line : bool, optional If watershed_line is True, a one-pixel wide line separates the regions obtained by the watershed algorithm.
原文: Watershed OpenCV - PyImageSearch https://pyimagesearch.com/2015/11/02/watershed-opencv/ 内容就先不说了,代码如下 : class Watershed: def __init__(self): pass def process(self, image_path): # load perform a connected component analysis on the local peaks, # using 8-connectivity, then appy the Watershed algorithm markers = ndimage.label(localMax, structure=np.ones((3, 3)))[0] labels = watershed 255), 2) # show the output image cv2.imshow("Output", image) cv2.waitKey(0) w = Watershed2
种子点的标记没有太搞懂,这个算法的速度还是很快的 // watershed_test20140801.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" // // ch9_watershed image // This is an exact copy of the watershed.cpp demo using a morphologically eroded forground and background segmented image as the template // for the watershed quit the program\n" "\tr - restore the original image\n" "\tw or ENTER - run watershed cvZero( marker_mask ); cvZero( wshed ); cvShowImage( "image", img ); cvShowImage( "watershed
import cv2 import numpy as np from skimage.segmentation import felzenszwalb, slic, quickshift, watershed =watershed(gradient,markers=250,compactness=0.001)#Compact watershed segmentation分割 print('Compact watershed (img,segments_watershed)#标记边界 cv2.imshow("result",result) cv2.waitKey() cv2.destroyAllWindows() Compact watershed segmentation number of segments: 256 算法:分水岭算法(Compact watershed segmentation)计算图像中已给定标记浸没的分水岭的各集水盆 dst=skimage.segmentation.watershed(img, markerse, connectivity, offset, mask, compactness, watershed_line
The Watershed Boundary Dataset (WBD) is a comprehensive aggregated collection of hydrologic unit (HU) there could be multiple outlets as stated by the Federal Standards and Procedures for the National Watershed Watershed boundaries are determined solely upon science-based hydrologic principles, not favoring any The Watershed Boundary Dataset (WBD) was created from a variety of sources from each state and aggregated Watershed Boundary Dataset for HUC# [Online WWW].
而分水岭方法完成之后并不会直接生成分割后的图像,还需要进一步的显示处理,如此看来,只有两个参数的watershed其实并不简单。 下边通过图示来看一下watershed函数的第二个参数markers在算法执行前后发生了什么变化。 总的概括一下watershed图像自动分割的实现步骤: 1. 图像灰度化、滤波、Canny边缘检测 2. 查找轮廓,并且把轮廓信息按照不同的编号绘制到watershed的第二个入参merkers上,相当于标记注水点。 3. watershed分水岭运算 4. 以下是Opencv分水岭算法watershed实现的完整过程: [cpp] view plain copy print ?
OpenCV 4提供了用于实现分水岭法分割图像的watershed()函数,该函数的函数原型在代码清单8-19中给出。 代码清单8-19 watershed()函数原型 void cv::watershed(InputArray image, InputOutputArray 为了了解该函数的用法,在代码清单8-20中给出了利用watershed()函数对图像进行分割的示例程序。 namespace std; using namespace cv; int main() { Mat img, imgGray, imgMask; Mat maskWaterShed; // watershed , contours, index, Scalar::all(index + 1), -1, 8, hierarchy, INT_MAX); } //分水岭算法 需要对原图像进行处理 watershed
.^2); figure,imshow(g); L=watershed(g); figure,imshow(L); wr=L==0; g2=imclose(imopen(g,ones(3,3)),ones (3,3)); figure,imshow(g2); L2=watershed(g2); figure,imshow(L2); wr2=L2==0; f2=f; f2(wr2)=255; figure, 'sobel'); fd=double(f); g=sqrt(imfilter(fd,h,'replicate').^2+... imfilter(fd,h','replicate').^2); L=watershed ,imshow(rm); im=imextendedmin(f,2); figure,imshow(im); fim=f; fim(im)=175; figure,imshow(fim); Lim=watershed (bwdist(im)); figure,imshow(Lim); em=Lim==0; g2=imimposemin(g,im|em); figure,imshow(g2); L2=watershed
// watershed_test20140801.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" // // ch9_watershed image // This is an exact copy of the watershed.cpp demo using a morphologically eroded forground and background segmented image as the template // for the watershed quit the program\n" "\tr - restore the original image\n" "\tw or ENTER - run watershed cvZero( marker_mask ); cvZero( wshed ); cvShowImage( "image", img ); cvShowImage( "watershed
import the necessary packages from skimage.feature import peak_local_max from skimage.morphology import watershed # perform a connected component analysis on the local peaks, # using 8-connectivity, then appy the Watershed algorithm markers = ndimage.label(localMax, structure=np.ones((3, 3)))[0] labels = watershed(-D, markers segments found".format(len(np.unique(labels)) - 1)) # loop over the unique labels returned by the Watershed 基本就是二值化和形态学操作 粘连分割---距离变换少不了 分水岭算法---根据实际情况使用,有时候分割不太可控,慎用 参考资料: https://www.pyimagesearch.com/2015/11/02/watershed-opencv
如今,Watershed Bio 正在帮助科学家和生物信息学家运行实验并获得见解。该平台允许用户分析复杂的数据集,无论其计算技能如何。 “有了 Watershed,他们就不必了。”Watershed 正被工业界和学术界的各种规模的研究团队使用,以推动发现和决策。 当科学期刊描述新的先进分析技术时,可以立即将其作为模板添加到 Watershed 的平台中,使前沿工具对所有背景的研究人员来说都更容易获取和协作。 加速生物学Wang 相信 Watershed 正在帮助生物学家跟上生物学的最新进展,并在此过程中加速科学发现。 Watershed 正被学术界和各种规模公司的研究人员使用。生物技术和制药公司的高管也使用 Watershed 来就新实验和候选药物做出决策。
markers) markers = markers + 1 markers[unknown == 255] = 0 waterimg[markers == -1] = 255 markers = cv.watershed 161: error: (-215:Assertion failed) src.type() == CV_8UC3 && dst.type() == CV_32SC1 in function 'cv::watershed ' 意思是该函数正在尝试将8通道的转为32通道 解决方法 markers = cv.watershed(img, markers) 该函数中img必须为三通道,即不能为灰度图或二值图像,可以用cvtcolor
cv2.DIST_L2, 5) ret, sure_fg = cv2.threshold(distance, 0.7*distance.max(), 255, 0) # Perform the watershed = markers+1 # Now, mark the region of unknown with zero markers[unknown==255] = 0 markers = cv2.watershed
分水岭算法 Watershed Algorithm(分水岭算法),顾名思义,就是根据分水岭的构成来考虑图像的分割。现实中我们可以或者说可以想象有山有湖的景象,那么那一定是水绕 山,山围水的情形。 而区分高山(plateaus)与水的界线,以及湖与湖之间的间隔或 都是连通的关系,就是我们可爱的分水岭(watershed)。 D = bwdist(bw); DL = watershed(D); bgm = DL == 0; figure('units', 'normalized','Name','背景标记'); subplot L = watershed(gradmag2); It1 = rgb(:,:, 1); It2 = rgb(:, :, 2); It3 = rgb(:, :, 3); fgm5 = imdilate(L 标记矩阵, % 比如通过watershed和bwlabel得到的,可以使用label2rgb转换到真彩图像来显示。
Deep Watershed Transform for Instance Segmentation (CVPR 2017) 这篇 instance segmentation 的论文在 mask rcnn 之前,这篇论文提出了学习一种类似于 watershed transform 的能量。 Watershed transform 可以直接计算,但是由于自然图像的复杂使得结果有很多 local minimal,通过 deep learning 学习到的势能会更加稳定,如下图: ? 网络通过 GT angle 和 watershed energy 两种 supervision 训练得到。两种能量可以通过 mask 标注产生,Ground-truth 如下图: ? Cityscape 上面 Watershed,SGN 和 Mask RCNN 的比较 ? COCO 数据集 Mask RCNN 跟 MaskLab 比较 ?
cv2.watershed(image, markers) image:输入图像 markers:标记 二、基于距离的分水岭分割流程 输入图像,有噪声的话,先进行去噪。 : 叶庭云 @CSDN : https://yetingyun.blog.csdn.net/ """ import cv2 as cv import numpy as np def watershed_algorithm 标签图像将会被修改,边界区域的标记将变为 -1 markers = cv.watershed(image, markers=markers) image[markers == -1] = /test/042.png') src = cv.resize(src, None, fx=0.5, fy=0.5) cv.imshow('input image', src) watershed_algorithm
% 不能用分水岭变换直接在梯度幅度上分割图像 L = watershed(gmag); Lrgb = label2rgb(L); imshow(Lrgb) title('直接在梯度幅度上分割图像') 我们不希望背景标记太靠近我们要分割的对象的边缘 % 通过计算前景的“阴影骨架”来“细化”背景(欧氏距离变换bwdist) % 可以通过计算距离变换的分水岭变换、然后寻找结果的分水岭线来实现 D = bwdist(bw); DL = watershed imimposemin修改渐变幅度图像 % 使其唯一的区域最小值出现在前景和背景标记像素上 gmag2 = imimposemin(gmag, bgm | fgm4); % 最后,我们准备好计算基于分水岭的分割 L = watershed
目标 在本章中,将学习 使用分水岭算法实现基于标记的图像分割 函数:cv2.watershed() 理论 任何灰度图像都可以看作是一个地形表面,其中高强度的像素表示山峰,低强度表示山谷。 这就是Watershed(分水岭算法)背后的“思想”。 但是这种方法会由于图像中的噪声或其他不规则性而产生过度分割的结果。 在执行分水岭函数watershed之前,必须对第二个参数markers进行处理,它应该包含不同区域的轮廓,每个轮廓有一个自己唯一的编号,轮廓的定位可以通过Opencv中findContours方法实现, 而分水岭方法完成之后并不会直接生成分割后的图像,还需要进一步的显示处理,如此看来,只有两个参数的watershed其实并不简单。 CMM page on Watershed Transformation https://zhuanlan.zhihu.com/p/67741538 https://blog.csdn.net/dcrmg