We used the Grabcut algorithm to perform 2D segmentation in an image that provides rough segmentation between the background and foreground. The intricate details of the algorithm are as follows.
- The user inserts an image into the interface wherein their finger nails are clearly visible. Our app takes the outside area beyond the nails as a sure background area. The inside area is unknown. The background and foreground won’t change in the process.
- After that our app uses the Gaussian Mixture Model(GMM) to model the background and foreground.
- Based on our data, GMM learns and creates pixel distribution. The unknown pixels are labelled as either probable background or probable foreground based on their relation with other hard-labelled pixels as per color statistics.
- Then a graph is built in the app from pixel distribution with the nodes in the graphs being the pixels. Source and sink nodes are added where every foreground pixel is connected to a source node and every background pixel is linked to a sink node.
- Then the connecting pixels to the source node are taken and their weights are defined by the probability of pixel being foreground/background. Edge information defines the weights between the pixels. If the difference in pixel color is large then the edge between them will get a low weight.
- Post that our app uses mincut algorithm to segment the graph which uses a minimum cost function and cuts the graph into sink node and source node. The cost function is written in our app as the sum of all weights of the edges that are cut. After this process the pixels connected to the source node turns into foreground and those connected to the sink node become the background.
- Until the classification converges this process continues throughout.
To bring about an improvement in detection, the ‘random walker algorithm’ was being used..
This determines the image segmentation from a set of markers labelling several phases. To produce segmentation, the image is treated as a graph and certain energy functionals are minimized. We also had to remove specular highlights which are bright spots of light appearing on shiny objects when illuminated. We removed it by the threshold method. What resulted was a clear and concise nail area which could be overlayed with any color the user desires.