grabcut | GrabCut implementation

 by   luiscarlosgph C++ Version: 0.5.0 License: MIT

kandi X-RAY | grabcut Summary

kandi X-RAY | grabcut Summary

grabcut is a C++ library. grabcut has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

This repository contains a library (and exemplary programs in C++ and Python that use the library). It implements GrabCut with CUDA-based Gaussian Mixture Models, and works seamlessly in C++ and Python (see minimal code snippets below). The code has been tested under the following configuration:.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              grabcut has a low active ecosystem.
              It has 4 star(s) with 0 fork(s). There are 2 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 0 open issues and 1 have been closed. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of grabcut is 0.5.0

            kandi-Quality Quality

              grabcut has 0 bugs and 0 code smells.

            kandi-Security Security

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

            kandi-License License

              grabcut 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

              grabcut releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.
              It has 196 lines of code, 8 functions and 6 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of grabcut
            Get all kandi verified functions for this library.

            grabcut Key Features

            No Key Features are available at this moment for grabcut.

            grabcut Examples and Code Snippets

            No Code Snippets are available at this moment for grabcut.

            Community Discussions

            QUESTION

            How to detect white pixels in a specified x,y location
            Asked 2021-Sep-30 at 14:54

            I have an image that I mask and crop in OpenCV with the given x,y coordinates. I also tried to detect and show the white pixels in said image which works fine now thanks to the help of an answer I got in another Stackoverflow post.

            I currently have the following:

            ...

            ANSWER

            Answered 2021-Sep-30 at 14:54

            You could sum the values of the pixels inside the square and if the number is above a certain threshold, there are non-black pixels. If you are absolutely sure the background is dead black, then you can check that the pixel value sum is non-zero to assert there are white pixels in the are you are evaluating.

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

            QUESTION

            Image Segmentation and Masking
            Asked 2021-Apr-27 at 15:29

            Need assistance with the simple task. I’m playing around with the LISC dataset that contains hematological images taken from peripheral blood and segmentation masks of manual ground truth for these graphical samples. The task is the following:

            1. Segment isolated leukocytes by removing/cropping irrelevant background elements using the segmentation masks given in the dataset. Try this on one sample only.
            2. Once accomplished, go through the whole folder, and segment/crop the rest of the samples.

            Results should be like this (these were obtained via a combination of Mask R-CNN, GrabCut, and OpenCV — but not suitable for the current project I’m working on):

            Here is the code that I’ve got so far (from jupyter notebook):

            ...

            ANSWER

            Answered 2021-Apr-27 at 15:29

            The change in colors is the result of the specified heatmap (viridis instead of binary) as noted above in comments.

            The output image has different coloration than the input image because OpenCV uses BGR rather than RGB for colors, so it's likely your red and blue channels are swapped. If you read an image with OpenCV and plot with Matplotlib or vice versa. There are two easy solutions:

            1.) Both read and plot images with OpenCV. You can replace plt.imshow(im_orig) with:

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

            QUESTION

            Add alpha channel to RGB image
            Asked 2021-Jan-21 at 14:24

            How can I add alpha channel to png image? Precisely I have the background using grabcut function, now I want to add it to the png image.

            After that I want to set the alpha channel to transparent by use of a mask

            ...

            ANSWER

            Answered 2021-Jan-21 at 14:24

            Here is fill channel approach.

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

            QUESTION

            How to separate human body from background in an image
            Asked 2021-Jan-10 at 18:25

            I have been trying to separate the human body in an image from the background, but all the methods I have seen don't seem to work very well for me.

            I have collected the following images;

            • The image of the background
            • The image of the background with the person in it.

            Now I want to cut out the person from the background. I tried subtracting the image of the background from the image with the person using res = cv2.subtract(background, foreground) (I am new to image processing).

            Background subtraction methods in opencv like cv2.BackgroundSubtractorMOG2() and cv2.BackgroundSubtractorMOG2() only works with videos or image sequence and contour detection methods I have seen are only for solid shapes.

            And grabCut doesn't quite work well for me because I would like to automate the process.

            Given the images I have (Image of the background and image of the background with the person in it), is there a method of cutting the person out from the background?

            ...

            ANSWER

            Answered 2021-Jan-01 at 13:51

            Since it is very easy to find dataset consist a lot of human body, I suggest you to implement neural network segmentation tecniques to extract human body perfectly. Please check this link to see similar example.

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

            QUESTION

            Outline of pixels after detecting object (without convex hull)
            Asked 2020-Oct-09 at 16:12

            The idea is to use grabcut (OpenCV) to detect the image inside a rectangle and create a geometry with Direct2D.

            My test image is this:

            After performing the grab cut, resulting in this image:

            the idea is to outline it. I can use an opacity brush to exclude it from the background but I want to use a geometric brush in order to be able to append/widen/combine geometries on it like all other selections in my editor (polygon, lasso, rectangle, etc).

            If I apply the convex hull algorithm to the points, I get this:

            Which of course is not desired for my case. How do I outline the image?

            After getting the image from the grabcut, I keep the points based on luminance:

            ...

            ANSWER

            Answered 2020-Oct-09 at 16:12

            For anyone interested, the solution is OpenCV contours. Working example here.

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

            QUESTION

            Python OpenCV: Crop image to contents, and make background transparent
            Asked 2020-Apr-02 at 17:05

            I have the following image:

            I want to crop the image to the actual contents, and then make the background (the white space behind) transparent. I have seen the following question: How to crop image based on contents (Python & OpenCV)?, and after looking at the answer, and trying it, I got the following code:

            ...

            ANSWER

            Answered 2020-Apr-02 at 17:05

            Here is one way to do that in Python/OpenCV.

            As I mentioned in my comment, your provided image has a white circle around the cow and then a transparent background. I have made the background fully white as my input.

            Input:

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

            QUESTION

            Python OpenCV doesn't give same output at the same image
            Asked 2020-Mar-31 at 21:15

            I'm trying to create a program that checks if 2 images are the same. I have the following code which gets executed with both the images:

            ...

            ANSWER

            Answered 2020-Mar-31 at 21:15

            cv2.grabCut doesn't give deterministic results because the GrabCut algorithm uses built in randomness.

            According to Wikipedia:

            This is used to construct a Markov random field over the pixel labels...

            You may avoid randomness by resetting the seed of the random generator of OpenCV before executing cv2.grabCut:

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

            QUESTION

            Is it possible to paste an image on top of another in OpenCV?
            Asked 2020-Mar-30 at 22:00

            I am fairly new to OpenCv and am creating a program that will segment a shoe from its background using GrabCut algorithm, then I want to paste the shoe onto a white background but I am struggling at that part.

            I tried cv2.add() to add the two images together but the two images have to be the same size and I can't guarantee that since the program prompts the user to upload the image.

            I have also tried whiteBgImg = 255 - grabCutImg to make the background white where the shoe isn't but it seems to affect the final image which is a problem as I need to perform feature detection and matching on the image.

            Thank you in advance for the advice! :)

            Original image: Original Shoe

            Final image (after grabcut and whiteBgImg = 255 - grabCutImg applied): Grabcut Shoe

            ...

            ANSWER

            Answered 2020-Mar-30 at 19:19

            If you want to put one image in front of the other image, you can do this as follows:

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

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

            Vulnerabilities

            No vulnerabilities reported

            Install grabcut

            These dependencies need to be installed no matter if you compile this repo from source or install it using pip.
            Python >= 3.8.2
            CUDA >= 8.0 (last tested to be working 11.0.2) # Ubuntu/Debian $ sudo apt update $ sudo apt install nvidia-cuda-toolkit
            OpenCV >= 3.4.3 (last tested to be working 4.5.1) # Ubuntu/Debian $ sudo apt update $ sudo apt install libopencv-dev python3-opencv
            Numpy >= 1.20.0 # Ubuntu/Debian $ sudo apt update $ sudo apt install python3-pip $ python3 -m pip install numpy --user
            libboost_python >= 1.70.0 (last tested to be working 1.75.0) $ wget https://dl.bintray.com/boostorg/release/1.75.0/source/boost_1_75_0.tar.gz $ tar xf boost_1_75_0.tar.gz $ cd boost_1_75_0/ $ ./bootstrap.sh --with-python=/usr/bin/python3 $ ./b2 --with-python link=static cxxflags="-std=c++11 -fPIC" variant=release stage $ sudo ./b2 --with-python link=static cxxflags="-std=c++11 -fPIC" variant=release install
            If you prefer to install this repo with pip, skip this section and continue to the next one.
            If you already compiled and installed this repo from source, do not install it again with pip.
            OpenCV
            Numpy

            Support

            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
            Install
          • PyPI

            pip install grabcut

          • CLONE
          • HTTPS

            https://github.com/luiscarlosgph/grabcut.git

          • CLI

            gh repo clone luiscarlosgph/grabcut

          • sshUrl

            git@github.com:luiscarlosgph/grabcut.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Consider Popular C++ Libraries

            tensorflow

            by tensorflow

            electron

            by electron

            terminal

            by microsoft

            bitcoin

            by bitcoin

            opencv

            by opencv

            Try Top Libraries by luiscarlosgph

            dockerx

            by luiscarlosgphPython

            t-Student-Mixture-Models

            by luiscarlosgphPython

            how-to

            by luiscarlosgphPerl

            synapi

            by luiscarlosgphPython

            keypoint-annotation-tool

            by luiscarlosgphPython