watershed | Python implementation of the watershed image segmentation | Computer Vision library

 by   mzur Python Version: Current License: MIT

kandi X-RAY | watershed Summary

kandi X-RAY | watershed Summary

watershed is a Python library typically used in Artificial Intelligence, Computer Vision, OpenCV applications. watershed has no bugs, it has no vulnerabilities, it has a Permissive License and it has high support. However watershed build file is not available. You can download it from GitHub.

A simple (but not very fast) Python implementation of Determining watersheds in digital pictures via flooding simulations. In contrast to skimage.morphology.watershed and cv2.watershed this implementation does not use marker seeds.

            kandi-support Support

              watershed has a highly active ecosystem.
              It has 43 star(s) with 28 fork(s). There are 2 watchers for this library.
              It had no major release in the last 6 months.
              There are 1 open issues and 0 have been closed. On average issues are closed in 780 days. There are no pull requests.
              It has a positive sentiment in the developer community.
              The latest version of watershed is current.

            kandi-Quality Quality

              watershed has 0 bugs and 0 code smells.

            kandi-Security Security

              watershed has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              watershed code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              watershed is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              watershed releases are not available. You will need to build from source code and install.
              watershed has no build file. You will be need to create the build yourself to build the component from source.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed watershed and discovered the below as its top functions. This is intended to give you an instant insight into watershed implemented functionality, and help decide if they suit your requirements.
            • Flatten an image
            • Get the neighbors of the given pixel
            Get all kandi verified functions for this library.

            watershed Key Features

            No Key Features are available at this moment for watershed.

            watershed Examples and Code Snippets

            No Code Snippets are available at this moment for watershed.

            Community Discussions


            Batch process for singel double positive particles in Image J
            Asked 2022-Mar-29 at 13:03

            This is my second go at writing a macro (with virtually zero coding knowledge) after the first one was a success, but I am adding a layer of complexity that I can't seem to make functional.

            I am trying to set up a batch process where I count particles of 2 different colors and then which of those particles is positive for both colors. I am getting this error:

            Error: ')' expected in line 38: selectWindow ( "Result of " - "+Title" ) ;

            I really don't know what I need to fix because it seems that I have closed all open parentheses. However, I know that the root issue is that I don't know how to generically name the window I am interested in. It is a window that is created by the macro and is not one of the input files.



            Answered 2022-Mar-29 at 13:03

            I think, that you just have to change the whole name in to a string

            Source https://stackoverflow.com/questions/71622143


            imextendedmin and imimposemin functions in python for watershed seeds from distance transform
            Asked 2022-Mar-28 at 18:48

            In matlab, I can use these functions from the image processing toolbox in order to "clean" a distance transform and locate the seeds for watershed algorithm. The tutorials I found for python include thresholding the distance transform to get the seeds, which doesnt work well in my case because not all my features are the same size, and the intensity of the distance transform depends on absolute distance from the background.

            I have attached an example of what those functions accomplish in matlab, where the white regions are the seeds. Is there a way I can achieve this in python, either with existing functions or coding it on my own?



            Answered 2022-Mar-28 at 18:48

            Matlab documentation credits Soille, P. Morphological Image Analysis: Principles and Applications. Springer-Verlag, 1999 for most of it's image morphology stuff. It's a really good read when trying to translate these functions.


            imextendedmin() gets the regional minima of the H-minima transform, where the H-minima transform is just morphological reconstruction by erosion of the image using (image + H) as the marker. Scikit-image has all the morphology tools needed to do this:

            Source https://stackoverflow.com/questions/70251361


            How to import Skimage to segment an image with watershed?
            Asked 2022-Mar-14 at 01:01

            I'm trying to use Skimage to segment an image with watershed, but I always get this error. Do you have a solution please?

            AttributeError: module 'skimage.morphology' has no attribute 'watershed'

            Source code : https://scikit-image.org/docs/0.12.x/auto_examples/xx_applications/plot_coins_segmentation.html



            Answered 2022-Mar-14 at 01:01

            You are for some reason looking at the old documentation for scikit-image, version 0.12. (See the 0.12.x in the URL that you shared.) You can look at the examples for the latest released version at:


            Concretely for your code, you need to update the import to from skimage.segmentation import watershed.

            Source https://stackoverflow.com/questions/71461134


            How can I make all background white in a binary image
            Asked 2022-Feb-27 at 22:27

            In the image I would like to have only the lungs in black not the background. The background [Top black and bottom black area of the image] must be white not black. How can I do that in python?. Code that resuls in the image above from an original grayscale image ("image") is:



            Answered 2022-Feb-27 at 22:27

            Assuming we have the segmentation image as posted above, and we want to fill the surrounding background with while.

            One option is iterating the borders, and apply floodFill where pixel is black:

            Source https://stackoverflow.com/questions/71265019


            C++ and OpenCV 4.5.3 - (-215: Assertion failed)
            Asked 2022-Feb-05 at 20:32
            Problem : Watershed algorithm

            I started app project, for image processing, using OpenCv 4.5.3 and Swift ( with C++ ). I'm fighting with watershaded alg. for a really long time... And i have no clue what did i do wrong. Just don't know...

            Error :



            Answered 2022-Feb-05 at 20:32

            The convertTo can not add channels as well can not reduce/convert image to image with smaller amount of channels. The key in this case is to use :

            Source https://stackoverflow.com/questions/70918454


            How to create a binary 3-dimensional matrix of ellipsoids with centers from a list of points in Python?
            Asked 2021-Oct-05 at 04:27
            The Goal

            I have an M-length array of 3-dimensional coordinate points as floats. I would like to create a 3-dimensional numpy array of a predefined shape filled with ellipsoids of a given float radius centered on these points. Because this is intended for image manipulation, I call each value in the array a "pixel". If these ellipsoids overlap, I would like to assign the pixel to the closer center by euclidean distance. The final output will be a numpy array with a background of 0 and pixels within ellipsoids numbered 1, 2,... M, as corresponding to the initial list of coordinates, similar to the output of scipy's ndimage.label(...).

            Below, I have a naive approach which considers every position in the output array and compares it to every defined center, creating a binary array with a value of 1 for any pixel inside any ellipsoid. It then uses scikit-image to watershed this binary array. While this code works, it is prohibitively slow for my use, both because it considers every pixel and center pair and because it performs watershedding seperately. How can I speed up this code?

            Naive Example ...


            Answered 2021-Oct-05 at 00:02

            Very cool project. Thank you. The following code adds an ellipsoid to an existing array. Since my method does not rely on checking every pixel I don't think the total size of the picture should matter. It will depend mostly on the amount of ellipsoid and the radii. For your example radii it takes about ~209 ms ± 8.44 ms. So if all the other radii have similar size it should take ~8.36 s for your 40 points/ellipsoids. Which sounds feasible to me.

            Also I believe this could be made faster using the symmetry of the ellipsoid. If one considers planes parallel to the coordinate planes going threw the center of the ellipsoid. Those planes divide the ellipsoid into 8 congruent parts. I believe one could calculate just one and mirror it into the other 7.

            Source https://stackoverflow.com/questions/69442181


            How can I delineate multiple watersheds in R using the streamstats package?
            Asked 2021-Sep-25 at 20:07

            There is an R package in development that I would like to use called streamstats. What it does is delineate a watershed (within the USA) for a latitude & longitude point along a body of water and provides watershed characteristics such as drainage area and proportions of various land covers. What I would like to do is extract some watershed characteristics of interest from a data frame of several lat & long positions.

            I can get the package to do what I want for one point



            Answered 2021-Sep-23 at 07:00

            I would put what you have in a function then use purrr::pmap_df() to loop through each row in dat1 then bind all the results together. See also this answer

            Source https://stackoverflow.com/questions/69294130


            Simple Image Segmentation OpenCV-Watershed
            Asked 2021-Sep-22 at 18:08

            I'm still pretty new within the image-segmentation / OpenCV scene and hope you can help me out. Currently, I'm trying to calculate the percentage of the 2 liquids within this photo

            It should be something like this (as an example)

            I thought opencv watershed could help me but I'm unable to get it right. I'm trying to set the markers manually but I get the following error: (-215:Assertion failed) src.type() == CV_8UC3 && dst.type() == CV_32SC1 in function 'cv::watershed' (probably I got my markers all wrong)

            If anyone can help me (maybe there is a better way to do this), I would greatly appreciate it

            This is the code I use:



            Answered 2021-Sep-21 at 20:18

            First of all, you obtain an exception because OpenCV's watershed() function expects markers array to be made of 32-bit integers. Converting it forth and back will remove the errors:

            Source https://stackoverflow.com/questions/69192148


            SQL - Get PDF items that do NOT have a matching PNG item. Or maybe get PDF items with no PNG item
            Asked 2021-Sep-15 at 20:20

            I have a table of metadata about attachments. Sometimes the auto PDF conversion does not work and it does not create a PNG file. I want a query I can run to see which PDF files this is happening on so I can go fix it..

            In this case I want the results:



            Answered 2021-Sep-15 at 20:20

            Assuming you always have .pdf data, but the .png may not convert as mentioned:

            Source https://stackoverflow.com/questions/69197311


            Selenium - Unable to Locate Element even after verifying
            Asked 2021-Sep-08 at 03:50

            This has worked fine for months, but throws errors now. It's a pretty simple code: open Chrome and pull an element out. It's now telling me that it's unable to locate the element.

            I've inspected the element with the Chrome window open and verify the XPATH and it matches to what is in the code exactly. I've taken a screenshot of the page it's running on and it all looks fine.

            What am I missing?



            Answered 2021-Sep-08 at 03:50

            May its because you have not put any waits.

            Either apply Implicit wait :

            Source https://stackoverflow.com/questions/69094205

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network


            No vulnerabilities reported

            Install watershed

            You can download it from GitHub.
            You can use watershed like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.


            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
          • HTTPS


          • CLI

            gh repo clone mzur/watershed

          • sshUrl


          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link