├── 2018Proj1_train ├── 10.1.png ├── 10.4.png ├── 14.png ├── 2.14.png ├── 2.2.png ├── 2.3.png ├── 2.6.png ├── 2.8.png ├── 2_3.1.png ├── 3.1.png ├── 3.10.png ├── 3.11.png ├── 3.2.png ├── 3.4.png ├── 3.8.png ├── 4.1.png ├── 4.10.png ├── 4.2.png ├── 4.3.png ├── 4.4.png ├── 4.5.png ├── 4.6.png ├── 4.7.png ├── 4.8.png ├── 5.1.png ├── 5.10.png ├── 5.11.png ├── 5.2.png ├── 5.3.png ├── 5.4.png ├── 5.5.png ├── 5.6.png ├── 5.9.png ├── 6.1.png ├── 6.3.png ├── 6.4.png ├── 6.5.png ├── 6.6.png ├── 6.7.png ├── 6.8.png ├── 7.2.png ├── 7.3.png ├── 7.4.png ├── 7.6.png ├── 8.2.png ├── 8.3.png ├── 8.4.png ├── 8.5.png ├── 9.2.png └── 9.3.png ├── EM Output ├── 001RED.png ├── 002RED.png ├── 003RED.png ├── 004RED.png ├── 005RED.png ├── 006RED.png ├── 007RED.png ├── 008RED.png ├── 009RED.png ├── 010RED.png ├── 10.1RED.png ├── 10.4RED.png ├── 14RED.png ├── 2.14RED.png └── 2.2RED.png ├── Final Output ├── 001Final.png ├── 002Final.png ├── 003Final.png ├── 004Final.png ├── 005Final.png ├── 006Final.png ├── 007Final.png ├── 008Final.png ├── 009Final.png ├── 010Final.png ├── 10.1Final.png ├── 10.4Final.png ├── 14Final.png └── 2.14Final.png ├── README.md ├── Test Images ├── 001.png ├── 002.png ├── 003.png ├── 004.png ├── 005.png ├── 006.png ├── 007.png ├── 008.png ├── 009.png └── 010.png ├── annotate.py ├── calculateBarrelmeasures.py ├── createX.py ├── em.py ├── images ├── formula.png ├── fov1.png └── fov2.png ├── mean.npy ├── roipoly.py ├── sigma.npy ├── weights.npy ├── xtrain.npy └── xtrain └── xtrain.npy /2018Proj1_train/10.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/10.1.png -------------------------------------------------------------------------------- /2018Proj1_train/10.4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/10.4.png -------------------------------------------------------------------------------- /2018Proj1_train/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/14.png -------------------------------------------------------------------------------- /2018Proj1_train/2.14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/2.14.png -------------------------------------------------------------------------------- /2018Proj1_train/2.2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/2.2.png -------------------------------------------------------------------------------- /2018Proj1_train/2.3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/2.3.png -------------------------------------------------------------------------------- /2018Proj1_train/2.6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/2.6.png -------------------------------------------------------------------------------- /2018Proj1_train/2.8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/2.8.png -------------------------------------------------------------------------------- /2018Proj1_train/2_3.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/2_3.1.png -------------------------------------------------------------------------------- /2018Proj1_train/3.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/3.1.png -------------------------------------------------------------------------------- /2018Proj1_train/3.10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/3.10.png -------------------------------------------------------------------------------- /2018Proj1_train/3.11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/3.11.png -------------------------------------------------------------------------------- /2018Proj1_train/3.2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/3.2.png -------------------------------------------------------------------------------- /2018Proj1_train/3.4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/3.4.png -------------------------------------------------------------------------------- /2018Proj1_train/3.8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/3.8.png -------------------------------------------------------------------------------- /2018Proj1_train/4.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/4.1.png -------------------------------------------------------------------------------- /2018Proj1_train/4.10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/4.10.png -------------------------------------------------------------------------------- /2018Proj1_train/4.2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/4.2.png -------------------------------------------------------------------------------- /2018Proj1_train/4.3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/4.3.png -------------------------------------------------------------------------------- /2018Proj1_train/4.4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/4.4.png -------------------------------------------------------------------------------- /2018Proj1_train/4.5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/4.5.png -------------------------------------------------------------------------------- /2018Proj1_train/4.6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/4.6.png -------------------------------------------------------------------------------- /2018Proj1_train/4.7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/4.7.png -------------------------------------------------------------------------------- /2018Proj1_train/4.8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/4.8.png -------------------------------------------------------------------------------- /2018Proj1_train/5.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/5.1.png -------------------------------------------------------------------------------- /2018Proj1_train/5.10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/5.10.png -------------------------------------------------------------------------------- /2018Proj1_train/5.11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/5.11.png -------------------------------------------------------------------------------- /2018Proj1_train/5.2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/5.2.png -------------------------------------------------------------------------------- /2018Proj1_train/5.3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/5.3.png -------------------------------------------------------------------------------- /2018Proj1_train/5.4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/5.4.png -------------------------------------------------------------------------------- /2018Proj1_train/5.5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/5.5.png -------------------------------------------------------------------------------- /2018Proj1_train/5.6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/5.6.png -------------------------------------------------------------------------------- /2018Proj1_train/5.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/5.9.png -------------------------------------------------------------------------------- /2018Proj1_train/6.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/6.1.png -------------------------------------------------------------------------------- /2018Proj1_train/6.3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/6.3.png -------------------------------------------------------------------------------- /2018Proj1_train/6.4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/6.4.png -------------------------------------------------------------------------------- /2018Proj1_train/6.5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/6.5.png -------------------------------------------------------------------------------- /2018Proj1_train/6.6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/6.6.png -------------------------------------------------------------------------------- /2018Proj1_train/6.7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/6.7.png -------------------------------------------------------------------------------- /2018Proj1_train/6.8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/6.8.png -------------------------------------------------------------------------------- /2018Proj1_train/7.2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/7.2.png -------------------------------------------------------------------------------- /2018Proj1_train/7.3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/7.3.png -------------------------------------------------------------------------------- /2018Proj1_train/7.4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/7.4.png -------------------------------------------------------------------------------- /2018Proj1_train/7.6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/7.6.png -------------------------------------------------------------------------------- /2018Proj1_train/8.2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/8.2.png -------------------------------------------------------------------------------- /2018Proj1_train/8.3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/8.3.png -------------------------------------------------------------------------------- /2018Proj1_train/8.4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/8.4.png -------------------------------------------------------------------------------- /2018Proj1_train/8.5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/8.5.png -------------------------------------------------------------------------------- /2018Proj1_train/9.2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/9.2.png -------------------------------------------------------------------------------- /2018Proj1_train/9.3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/2018Proj1_train/9.3.png -------------------------------------------------------------------------------- /EM Output/001RED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/EM Output/001RED.png -------------------------------------------------------------------------------- /EM Output/002RED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/EM Output/002RED.png -------------------------------------------------------------------------------- /EM Output/003RED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/EM Output/003RED.png -------------------------------------------------------------------------------- /EM Output/004RED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/EM Output/004RED.png -------------------------------------------------------------------------------- /EM Output/005RED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/EM Output/005RED.png -------------------------------------------------------------------------------- /EM Output/006RED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/EM Output/006RED.png -------------------------------------------------------------------------------- /EM Output/007RED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/EM Output/007RED.png -------------------------------------------------------------------------------- /EM Output/008RED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/EM Output/008RED.png -------------------------------------------------------------------------------- /EM Output/009RED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/EM Output/009RED.png -------------------------------------------------------------------------------- /EM Output/010RED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/EM Output/010RED.png -------------------------------------------------------------------------------- /EM Output/10.1RED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/EM Output/10.1RED.png -------------------------------------------------------------------------------- /EM Output/10.4RED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/EM Output/10.4RED.png -------------------------------------------------------------------------------- /EM Output/14RED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/EM Output/14RED.png -------------------------------------------------------------------------------- /EM Output/2.14RED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/EM Output/2.14RED.png -------------------------------------------------------------------------------- /EM Output/2.2RED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/EM Output/2.2RED.png -------------------------------------------------------------------------------- /Final Output/001Final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Final Output/001Final.png -------------------------------------------------------------------------------- /Final Output/002Final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Final Output/002Final.png -------------------------------------------------------------------------------- /Final Output/003Final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Final Output/003Final.png -------------------------------------------------------------------------------- /Final Output/004Final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Final Output/004Final.png -------------------------------------------------------------------------------- /Final Output/005Final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Final Output/005Final.png -------------------------------------------------------------------------------- /Final Output/006Final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Final Output/006Final.png -------------------------------------------------------------------------------- /Final Output/007Final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Final Output/007Final.png -------------------------------------------------------------------------------- /Final Output/008Final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Final Output/008Final.png -------------------------------------------------------------------------------- /Final Output/009Final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Final Output/009Final.png -------------------------------------------------------------------------------- /Final Output/010Final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Final Output/010Final.png -------------------------------------------------------------------------------- /Final Output/10.1Final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Final Output/10.1Final.png -------------------------------------------------------------------------------- /Final Output/10.4Final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Final Output/10.4Final.png -------------------------------------------------------------------------------- /Final Output/14Final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Final Output/14Final.png -------------------------------------------------------------------------------- /Final Output/2.14Final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Final Output/2.14Final.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Color Segmentation using GMM 2 | ============================ 3 | 4 | In this project, I have implemented an approach for robust color segmentation which was further used to detect a red barrel based on shape statistics. The different color representations of red barrel contain variations in illumination, occlusion and tilt. This is the reason Gaussian Mixture Models was used to represent these variations. 5 | 6 | * Tested on: Kubuntu 16.04.3, Intel i5-4200U (4) @ 2.600GHz 4GB 7 | * Python 2.7, OpenCV 3.2 8 | 9 | # Expectation-Maximization Algorithm 10 | The expectation maximization algorithm is used to find out the mean, variances and weights in the of the different Gaussian Models that represent the red barrels in the training images. 11 | 12 | The GMM is represented by - 13 | 14 | ![](images/formula.png) 15 | 16 | # Barrel Detection 17 | After the red regions of the barrel had been segmented, to connect the known regions Contours were used. Contours connect similar points (having similar intensity or color values. 18 | 19 | Parameter Estimation is done by using the formula: The values were calculated and estimated by averaging from these 2 formulas: 20 | 21 | | Vertical FoV | Horizontal FoV | 22 | | ----------- | ----------- | 23 | | ![](images/fov1.png) | ![](images/fov2.png) | 24 | 25 | # Results 26 | 27 | | Test Images | Segmentation | Barrel Detection | 28 | | ----------- | ----------- | ----------- | 29 | | ![](2018Proj1_train/2.14.png) | ![](EM%20Output/2.14RED.png) | ![](Final%20Output/2.14Final.png) 30 | | ![](2018Proj1_train/10.1.png) | ![](EM%20Output/10.1RED.png) | ![](Final%20Output/10.1Final.png) 31 | | ![](Test%20Images/002.png) | ![](EM%20Output/002RED.png) | ![](Final%20Output/002Final.png) 32 | | ![](Test%20Images/003.png) | ![](EM%20Output/003RED.png) | ![](Final%20Output/003Final.png) 33 | | ![](Test%20Images/007.png) | ![](EM%20Output/007RED.png) | ![](Final%20Output/007Final.png) 34 | | ![](Test%20Images/009.png) | ![](EM%20Output/009RED.png) | ![](Final%20Output/009Final.png) 35 | | ![](Test%20Images/010.png) | ![](EM%20Output/010RED.png) | ![](Final%20Output/010Final.png) 36 | 37 | # Instructions 38 | Place the test images in "Test Images" 39 | 40 | * Run em.py to find out the optimal values for Mean, Variance and Weights and to Detect Barrels. 41 | Outputs of EM will be in folder --> 'EM Output' 42 | 43 | NOTE - You may need to run this more than once, sometimes it gives NaN values dueto random initialization. 44 | 45 | * Run calculateBarrelmeasures.py to calulate Barrel Box, Centroid and Distance. 46 | Outputs of Bounding Box and distance and height --> 'Final Output' 47 | -------------------------------------------------------------------------------- /Test Images/001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Test Images/001.png -------------------------------------------------------------------------------- /Test Images/002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Test Images/002.png -------------------------------------------------------------------------------- /Test Images/003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Test Images/003.png -------------------------------------------------------------------------------- /Test Images/004.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Test Images/004.png -------------------------------------------------------------------------------- /Test Images/005.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Test Images/005.png -------------------------------------------------------------------------------- /Test Images/006.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Test Images/006.png -------------------------------------------------------------------------------- /Test Images/007.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Test Images/007.png -------------------------------------------------------------------------------- /Test Images/008.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Test Images/008.png -------------------------------------------------------------------------------- /Test Images/009.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Test Images/009.png -------------------------------------------------------------------------------- /Test Images/010.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/Test Images/010.png -------------------------------------------------------------------------------- /annotate.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | import cv2, os 4 | from roipoly import roipoly 5 | import pdb 6 | 7 | 8 | 9 | 10 | ############################ 11 | ## MODIFY THESE VARIABLES ## 12 | ############################ 13 | inFolder = "2018Proj1_train/" 14 | outFolder = "labeled_data/" 15 | colorClass = "RedBarrel/" 16 | ############################ 17 | 18 | 19 | retry = True 20 | rois = [] 21 | 22 | def on_keypress(event, datafilename, img): 23 | global retry 24 | global rois 25 | if event.key == 'n': 26 | # save 27 | imgSize = np.shape(img) 28 | mask = np.zeros(imgSize[0:2], dtype=bool) 29 | for roi in rois: 30 | mask = np.logical_or(mask, roi.getMask2(imgSize)) 31 | np.save(datafilename, mask) 32 | print("Saving " + datafilename) 33 | plt.close() 34 | elif event.key == 'q': 35 | print("Quitting") 36 | exit() 37 | elif event.key == 'r': 38 | # retry 39 | print("Retry annotation") 40 | rois = [] 41 | retry = True 42 | plt.close() 43 | elif event.key == 'a': 44 | # add 45 | print("Add another annotation") 46 | retry = True 47 | plt.close() 48 | 49 | if __name__ == '__main__': 50 | inFolderPath = inFolder 51 | outFolderPath = outFolder + colorClass 52 | 53 | for filename in os.listdir(inFolderPath): 54 | basename, extension = os.path.splitext(filename) 55 | if (extension != ".png"): 56 | continue 57 | 58 | textfile = outFolderPath + basename + ".npy" 59 | if os.path.isfile(textfile): 60 | continue 61 | bgrImage = cv2.imread(inFolderPath + filename) 62 | rgbImg = cv2.cvtColor(bgrImage, cv2.COLOR_BGR2RGB) 63 | 64 | rois = [] 65 | retry = True 66 | while (retry): 67 | retry = False 68 | plt.cla() 69 | 70 | # draw region of interest 71 | plt.imshow(rgbImg, interpolation='none') 72 | for roi in rois: 73 | roi.displayROI() 74 | plt.title(basename) 75 | rois.append(roipoly(roicolor='r')) #let user draw ROI 76 | 77 | fig = plt.gcf() 78 | fig.canvas.mpl_connect('key_press_event', \ 79 | lambda event: on_keypress(event, outFolderPath + basename, rgbImg)) 80 | 81 | plt.cla() 82 | plt.imshow(rgbImg, interpolation='none') 83 | for roi in rois: 84 | roi.displayROI() 85 | plt.title("press \'n\' to save and go to next picture, \'r\' to retry \n \'q\' to quit, \'a\' to add another region") 86 | plt.show() 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /calculateBarrelmeasures.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import cv2 3 | import os 4 | import math 5 | 6 | xtrain = np.load('xtrain/xtrain.npy') 7 | xtrain_cov = np.transpose(xtrain) 8 | 9 | mean_red = np.mean(xtrain, axis=0) 10 | covariance_matrix_red = np.cov(xtrain_cov) 11 | 12 | def calcMeasures(im, orig_img, timg): 13 | imgray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY) 14 | ret, thresh = cv2.threshold(imgray, 50, 255, 0) 15 | im2, contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE) 16 | 17 | areas = [cv2.contourArea(c) for c in contours] 18 | 19 | heights = [] 20 | widths = [] 21 | dists_average = [] 22 | bottomLeftX = [] 23 | bottomLeftY = [] 24 | topRightY = [] 25 | topRightX = [] 26 | centroidX = [] 27 | centroidY = [] 28 | 29 | for c in contours: 30 | x, y, w, h = cv2.boundingRect(c) 31 | area = cv2.contourArea(c) 32 | if contours.__len__() > 1: 33 | if np.max(areas)/area <= 4.4: 34 | flag = 1 35 | else: 36 | flag = 0 37 | else: 38 | flag = 1 39 | h = float(h) 40 | w = float(w) 41 | 42 | if ((h/w) >= 1.15) and ((h/w) <= 2.6): 43 | if flag == 1: 44 | 45 | h = int(h) 46 | w = int(w) 47 | d_avg = 110.2058805/h + 74.58824/w 48 | bLeftX = x 49 | bLeftY = y+h 50 | tRightX = x+w 51 | tRightY=y 52 | centX=x+w/2. 53 | centY=y+h/2. 54 | 55 | cv2.rectangle(im, (x, y), (x + w, y + h), (0, 255, 0), 2) 56 | cv2.rectangle(orig_img, (x, y), (x + w, y + h), (0, 255, 0), 2) 57 | cv2.rectangle(timg, (x, y), (x + w, y + h), (0, 255, 0), 2) 58 | cv2.circle(orig_img, (int(centX), int(centY)), 1, (0, 255, 0), 2) 59 | 60 | bottomLeftX.append(bLeftX) 61 | bottomLeftY.append(bLeftY) 62 | topRightX.append(tRightX) 63 | topRightY.append(tRightY) 64 | centroidX.append(centX) 65 | centroidY.append(centY) 66 | 67 | heights.append(h) 68 | widths.append(w) 69 | dists_average.append(d_avg) 70 | 71 | 72 | return im, orig_img, timg, dists_average, centroidX, centroidY 73 | 74 | 75 | folder = "2018Proj1_train" 76 | infolder = "EM Output" 77 | final = "Final Output" 78 | i=0 79 | for filename in os.listdir(infolder): 80 | i=i+1 81 | basename = os.path.basename(filename) 82 | print basename 83 | img = cv2.imread(os.path.join(infolder,filename)) 84 | timg = cv2.imread(os.path.join(folder,filename)) 85 | cv2.imshow('Image', img) 86 | cv2.waitKey(0) 87 | 88 | im = img 89 | im = cv2.medianBlur(im, 5) 90 | morphimg = cv2.morphologyEx(im, cv2.MORPH_CLOSE, np.ones((10, 10), np.uint8)) 91 | 92 | bimg, res, timg, dist, centX, centY = calcMeasures(morphimg, img,timg) 93 | 94 | cv2.imshow('Barrel', res) 95 | cv2.waitKey(0) 96 | cv2.destroyAllWindows() 97 | 98 | cv2.imwrite(os.path.join(final, basename[:-7] + 'Final.png'), res) 99 | 100 | print "ImageNo = [0{0}], CentroidX = {1}, CentroidY = {2}, Distance = {3}".format(i,centX,centY,dist) 101 | -------------------------------------------------------------------------------- /createX.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import os 3 | import cv2 4 | 5 | xtrain = [] 6 | l=0 7 | for filename in os.listdir("./labeled_data/RedBarrel/"): 8 | l=l+1 9 | print l 10 | basename, extension = os.path.splitext(filename) 11 | if (extension != ".npy"): 12 | continue 13 | redbarrel = np.load('./labeled_data/RedBarrel/'+filename) 14 | img = cv2.imread('./2018Proj1_train/'+basename+'.png') 15 | img = cv2.cvtColor(img, cv2.COLOR_BGR2YCR_CB) 16 | tmp = img[redbarrel] 17 | for i in range(tmp.shape[0]): 18 | xtrain.append(tmp[i, :]) 19 | 20 | xtrain = np.array(xtrain) 21 | 22 | np.save('xtrain', xtrain) -------------------------------------------------------------------------------- /em.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pylab as plt 3 | import os 4 | import cv2 5 | from scipy.stats import multivariate_normal as mvn 6 | 7 | ######################################################################################## 8 | ######################################################################################## 9 | #Set Train = 1 for training 10 | Train = 1 11 | K=7 12 | 13 | #Set values here 14 | testfolder = "Test Images" 15 | outfolder = "EM Output" 16 | ######################################################################################## 17 | ######################################################################################## 18 | 19 | def EMalgo(xtrain,K,iters): 20 | 21 | n,d = xtrain.shape 22 | mean = xtrain[np.random.choice(n, K, False), :] 23 | Sigma = [80*np.eye(d)] * K 24 | for i in range(K): 25 | Sigma[i]=np.multiply(Sigma[i],np.random.rand(d,d)) 26 | #Sigma[i]=Sigma[i]*Sigma[i].T 27 | w = [1./K] * K 28 | z = np.zeros((n, K)) 29 | 30 | log_likelihoods = [] 31 | 32 | while len(log_likelihoods) < iters: 33 | for k in range(K): 34 | #x_mean = np.matrix(xtrain - mean[k]) 35 | #Sinv = np.linalg.pinv(Sigma[k]) 36 | tmp = w[k] * mvn.pdf(xtrain, mean[k], Sigma[k],allow_singular=True)#((2.0 * np.pi) ** (-d / 2.0)) * (1.0 / (np.linalg.det(Sigma[k]) ** 0.5)) * np.exp(-0.5 * np.sum(np.multiply(x_mean * Sinv, x_mean), axis=1)) 37 | z[:,k]=tmp.reshape((n,)) 38 | 39 | log_likelihood = np.sum(np.log(np.sum(z, axis = 1))) 40 | 41 | print '{0} -> {1}'.format(len(log_likelihoods),log_likelihood) 42 | if log_likelihood>-592596: break 43 | 44 | log_likelihoods.append(log_likelihood) 45 | 46 | z = (z.T / np.sum(z, axis = 1)).T 47 | 48 | N_ks = np.sum(z, axis = 0) 49 | 50 | for k in range(K): 51 | mean[k] = 1. / N_ks[k] * np.sum(z[:, k] * xtrain.T, axis = 1).T 52 | x_mean = np.matrix(xtrain - mean[k]) 53 | Sigma[k] = np.array(1 / N_ks[k] * np.dot(np.multiply(x_mean.T, z[:, k]), x_mean)) 54 | w[k] = 1. / n * N_ks[k] 55 | 56 | if len(log_likelihoods) < 2 : continue 57 | if len(log_likelihoods)>10000 or np.abs(log_likelihood - log_likelihoods[-2]) < 0.0001: break 58 | 59 | plt.plot(log_likelihoods) 60 | plt.title('Log Likelihood vs iteration plot') 61 | plt.xlabel('Iterations') 62 | plt.ylabel('log likelihood') 63 | plt.show() 64 | np.save('weights',w) 65 | np.save('sigma',Sigma) 66 | np.save('mean',mean) 67 | 68 | xtrain = np.load('xtrain.npy') 69 | 70 | if(Train == 1): 71 | EMalgo(xtrain,K,10000) 72 | 73 | w=np.load('weights.npy') 74 | Sigma=np.load('sigma.npy') 75 | mean=np.load('mean.npy') 76 | 77 | for filename in os.listdir(testfolder): 78 | 79 | img = cv2.imread(os.path.join(testfolder,filename)) 80 | cv2.imshow('Test', img) 81 | cv2.waitKey(0) 82 | cv2.destroyAllWindows() 83 | basename = os.path.basename(filename) 84 | print basename 85 | #img = cv2.cvtColor(img, cv2.COLOR_BGR2YCR_CB) 86 | nr, nc, d = img.shape 87 | n=nr*nc 88 | xtest=np.reshape(img,(n,d)) 89 | likelihoods=np.zeros((K,n)) 90 | log_likelihood=np.zeros(n) 91 | for k in range(K): 92 | #x_mean = np.matrix(xtrain - mean[k]) 93 | #Sinv = np.linalg.pinv(Sigma[k]) 94 | likelihoods[k] = w[k] * mvn.pdf(xtest, mean[k], Sigma[k],allow_singular=True)#((2.0 * np.pi) ** (-d / 2.0)) * (1.0 / (np.linalg.det(Sigma[k]) ** 0.5)) * np.exp(-0.5 * np.sum(np.multiply(x_mean * Sinv, x_mean), axis=1)) 95 | log_likelihood = likelihoods.sum(0) 96 | 97 | log_likelihood = np.reshape(log_likelihood, (nr, nc)) 98 | 99 | log_likelihood[log_likelihood > np.max(log_likelihood) / 1.18] = 255 100 | output_img = np.zeros(img.shape) 101 | output_img[:, :, 2] = log_likelihood 102 | output_img = np.array(output_img) 103 | output_img = cv2.resize(output_img, (400, 300)) 104 | 105 | cv2.imshow('RED',output_img) 106 | cv2.waitKey(0) 107 | cv2.destroyAllWindows() 108 | 109 | cv2.imwrite(os.path.join(outfolder, basename[:-4]+'RED'+'.png'), output_img) -------------------------------------------------------------------------------- /images/formula.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/images/formula.png -------------------------------------------------------------------------------- /images/fov1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/images/fov1.png -------------------------------------------------------------------------------- /images/fov2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/images/fov2.png -------------------------------------------------------------------------------- /mean.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/mean.npy -------------------------------------------------------------------------------- /roipoly.py: -------------------------------------------------------------------------------- 1 | '''Draw polygon regions of interest (ROIs) in matplotlib images, 2 | similar to Matlab's roipoly function. 3 | See the file example.py for an application. 4 | Created by Joerg Doepfert 2014 based on code posted by Daniel 5 | Kornhauser. 6 | ''' 7 | 8 | 9 | import numpy as np 10 | import sys 11 | import matplotlib.pyplot as plt 12 | import matplotlib.path as mplPath 13 | 14 | class roipoly: 15 | 16 | def __init__(self, fig=[], ax=[], roicolor='b'): 17 | if fig == []: 18 | fig = plt.gcf() 19 | 20 | if ax == []: 21 | ax = plt.gca() 22 | 23 | self.previous_point = [] 24 | self.allxpoints = [] 25 | self.allypoints = [] 26 | self.start_point = [] 27 | self.end_point = [] 28 | self.line = None 29 | self.roicolor = roicolor 30 | self.fig = fig 31 | self.ax = ax 32 | #self.fig.canvas.draw() 33 | 34 | self.__ID1 = self.fig.canvas.mpl_connect( 35 | 'motion_notify_event', self.__motion_notify_callback) 36 | self.__ID2 = self.fig.canvas.mpl_connect( 37 | 'button_press_event', self.__button_press_callback) 38 | 39 | if sys.flags.interactive: 40 | plt.show(block=False) 41 | else: 42 | plt.show() 43 | 44 | 45 | 46 | def getMask(self, currentImage): 47 | ny, nx = np.shape(currentImage) 48 | poly_verts = [(self.allxpoints[0], self.allypoints[0])] 49 | for i in range(len(self.allxpoints)-1, -1, -1): 50 | poly_verts.append((self.allxpoints[i], self.allypoints[i])) 51 | 52 | # Create vertex coordinates for each grid cell... 53 | # (<0,0> is at the top left of the grid in this system) 54 | x, y = np.meshgrid(np.arange(nx), np.arange(ny)) 55 | x, y = x.flatten(), y.flatten() 56 | points = np.vstack((x,y)).T 57 | 58 | ROIpath = mplPath.Path(poly_verts) 59 | grid = ROIpath.contains_points(points).reshape((ny,nx)) 60 | return grid 61 | 62 | def getMask2(self, size): 63 | ny = size[0] 64 | nx = size[1] 65 | poly_verts = [(self.allxpoints[0], self.allypoints[0])] 66 | for i in range(len(self.allxpoints)-1, -1, -1): 67 | poly_verts.append((self.allxpoints[i], self.allypoints[i])) 68 | 69 | # Create vertex coordinates for each grid cell... 70 | # (<0,0> is at the top left of the grid in this system) 71 | x, y = np.meshgrid(np.arange(nx), np.arange(ny)) 72 | x, y = x.flatten(), y.flatten() 73 | points = np.vstack((x,y)).T 74 | 75 | ROIpath = mplPath.Path(poly_verts) 76 | grid = ROIpath.contains_points(points).reshape((ny,nx)) 77 | return grid 78 | 79 | def getVertices(self): 80 | poly_verts = [(self.allxpoints[0], self.allypoints[0])] 81 | for i in range(len(self.allxpoints)-1, -1, -1): 82 | poly_verts.append((self.allxpoints[i], self.allypoints[i])) 83 | return poly_verts 84 | 85 | 86 | def displayROI(self,**linekwargs): 87 | l = plt.Line2D(self.allxpoints + 88 | [self.allxpoints[0]], 89 | self.allypoints + 90 | [self.allypoints[0]], 91 | color=self.roicolor, **linekwargs) 92 | ax = plt.gca() 93 | ax.add_line(l) 94 | plt.draw() 95 | 96 | def getLines(self,**linekwargs): 97 | return plt.Line2D(self.allxpoints + 98 | [self.allxpoints[0]], 99 | self.allypoints + 100 | [self.allypoints[0]], 101 | color=self.roicolor, **linekwargs) 102 | 103 | def displayMean(self,currentImage, **textkwargs): 104 | mask = self.getMask(currentImage) 105 | meanval = np.mean(np.extract(mask, currentImage)) 106 | stdval = np.std(np.extract(mask, currentImage)) 107 | string = "%.3f +- %.3f" % (meanval, stdval) 108 | plt.text(self.allxpoints[0], self.allypoints[0], 109 | string, color=self.roicolor, 110 | bbox=dict(facecolor='w', alpha=0.6), **textkwargs) 111 | 112 | def __motion_notify_callback(self, event): 113 | if event.inaxes: 114 | ax = event.inaxes 115 | x, y = event.xdata, event.ydata 116 | if (event.button == None or event.button == 1) and self.line != None: # Move line around 117 | self.line.set_data([self.previous_point[0], x], 118 | [self.previous_point[1], y]) 119 | self.fig.canvas.draw() 120 | 121 | 122 | def __button_press_callback(self, event): 123 | if self.fig.canvas.manager.toolbar._active != None: 124 | return 125 | if event.inaxes: 126 | x, y = event.xdata, event.ydata 127 | ax = event.inaxes 128 | if event.button == 1 and event.dblclick == False: # If you press the left button, single click 129 | if self.line == None: # if there is no line, create a line 130 | self.line = plt.Line2D([x, x], 131 | [y, y], 132 | marker='o', 133 | color=self.roicolor) 134 | self.start_point = [x,y] 135 | self.previous_point = self.start_point 136 | self.allxpoints=[x] 137 | self.allypoints=[y] 138 | 139 | ax.add_line(self.line) 140 | self.fig.canvas.draw() 141 | # add a segment 142 | else: # if there is a line, create a segment 143 | self.line = plt.Line2D([self.previous_point[0], x], 144 | [self.previous_point[1], y], 145 | marker = 'o',color=self.roicolor) 146 | self.previous_point = [x,y] 147 | self.allxpoints.append(x) 148 | self.allypoints.append(y) 149 | 150 | event.inaxes.add_line(self.line) 151 | self.fig.canvas.draw() 152 | elif ((event.button == 1 and event.dblclick==True) or 153 | (event.button == 3 and event.dblclick==False)) and self.line != None: # close the loop and disconnect 154 | self.fig.canvas.mpl_disconnect(self.__ID1) #joerg 155 | self.fig.canvas.mpl_disconnect(self.__ID2) #joerg 156 | 157 | self.line.set_data([self.previous_point[0], 158 | self.start_point[0]], 159 | [self.previous_point[1], 160 | self.start_point[1]]) 161 | ax.add_line(self.line) 162 | self.fig.canvas.draw() 163 | self.line = None 164 | 165 | if sys.flags.interactive: 166 | pass 167 | else: 168 | #figure has to be closed so that code can continue 169 | plt.close(self.fig) 170 | 171 | -------------------------------------------------------------------------------- /sigma.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/sigma.npy -------------------------------------------------------------------------------- /weights.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/weights.npy -------------------------------------------------------------------------------- /xtrain.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/xtrain.npy -------------------------------------------------------------------------------- /xtrain/xtrain.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashv28/Color-Segmentation-using-GMM/1d0b14fff4e87d056e24d340ac0446b3867e428b/xtrain/xtrain.npy --------------------------------------------------------------------------------