{"id":25445646,"url":"https://github.com/kisaa-fatima/foreground-segmentation-using-kmeans-face-recognization-using-knn","last_synced_at":"2026-05-03T05:39:28.673Z","repository":{"id":248355114,"uuid":"828468261","full_name":"Kisaa-Fatima/Foreground-segmentation-using-kmeans-Face-recognization-using-KNN","owner":"Kisaa-Fatima","description":"Implement a basic version of the interactive image cut-out/segmentation approach called Lazy Snapping. The program uses K-Means Clustering to segment images into foreground and background based on user-provided seed pixels.","archived":false,"fork":false,"pushed_at":"2024-07-14T08:50:18.000Z","size":17025,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-17T16:41:33.957Z","etag":null,"topics":["face-recognition","foreground-segmentation","kmeans-clustering","knn-classification","matplotlib","numpy","opencv2","pil"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kisaa-Fatima.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-14T08:41:26.000Z","updated_at":"2025-02-04T18:52:26.000Z","dependencies_parsed_at":"2024-07-14T10:07:35.057Z","dependency_job_id":null,"html_url":"https://github.com/Kisaa-Fatima/Foreground-segmentation-using-kmeans-Face-recognization-using-KNN","commit_stats":null,"previous_names":["kisaa-fatima/foreground-segmentation-using-kmeans-face-recognization-using-knn"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kisaa-Fatima%2FForeground-segmentation-using-kmeans-Face-recognization-using-KNN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kisaa-Fatima%2FForeground-segmentation-using-kmeans-Face-recognization-using-KNN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kisaa-Fatima%2FForeground-segmentation-using-kmeans-Face-recognization-using-KNN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kisaa-Fatima%2FForeground-segmentation-using-kmeans-Face-recognization-using-KNN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kisaa-Fatima","download_url":"https://codeload.github.com/Kisaa-Fatima/Foreground-segmentation-using-kmeans-Face-recognization-using-KNN/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254471056,"owners_count":22076587,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["face-recognition","foreground-segmentation","kmeans-clustering","knn-classification","matplotlib","numpy","opencv2","pil"],"created_at":"2025-02-17T16:32:20.114Z","updated_at":"2026-05-03T05:39:23.651Z","avatar_url":"https://github.com/Kisaa-Fatima.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Foreground-segmentation-using-kmeans-AND-Face-recognization-using-KNN\n\n## Interactive Foreground Segmentation and Face Recognition\nThis repository contains two main ASSIGNMENTS:\n\n- Interactive Foreground Segmentation Using K-Means Clustering\n- Face Recognition Using K-Nearest Neighbors (K-NN)\nEach ASSIGNMENT involves detailed data preprocessing, algorithm implementation, and result analysis. Below are the instructions and descriptions for each project.\n\n## Assignment 1: Interactive Foreground Segmentation Using K-Means Clustering\n## Objective\nImplement a basic version of the interactive image cut-out/segmentation approach called Lazy Snapping. The program uses K-Means Clustering to segment images into foreground and background based on user-provided seed pixels.\n\n## Libraries Used\ntime: To measure the processing time for segmentation.\nPIL (Image): For opening and manipulating images.\nmatplotlib.pyplot (plt): To display the segmentation results.\nnumpy: For numerical operations.\ncv2 (OpenCV): For image processing tasks like reading images, converting color spaces, and displaying images.\n## Solution\n- Segmentation Mask Processing:\n\nCreate three versions of the input image:\nOne with background pixels set to black.\nOne with foreground pixels set to black.\nThe original image.\n- Lazy Snapping:\n\nUtilize human annotations (foreground and background seed pixels) to compute a precise figure-ground segmentation.\n- Optimization:\n\nK-Means Optimization: Use Mini-batch K-Means for efficiency.\nReduce Color Space Dimensionality.\nParallelize K-Means computation for foreground and background classes.\nResults and Observations\n- N Values:\n\nIncreasing N results in more refined segmentation but increases computational complexity.\nLower N values provide coarse segmentation but reduce computation time.\n- Comparison:\n\nVarying N values and strokes impact segmentation consistency and robustness.\nRunning the Scripts\n\n## Assignment 2: Face Recognition Using K-Nearest Neighbors (K-NN)\n## Objective\nImplement a K-Nearest Neighbors classifier from scratch for face recognition using the CMU Pose, Illumination, and Expression (PIE) Dataset.\n\n## Libraries Used\n- numpy: For numerical operations.\n- matplotlib: For visualization.\n## Tasks\n- Pre-process the Dataset:\n\nNormalize each face image vector to unit length.\nSplit the dataset into training and testing sets.\n- Implement K-NN Classifier:\n\nUse Euclidean and cosine similarity distance measures.\nEvaluate performance for different k-values (2, 5, 7, 11).\n- Apply SVM and GaussianNB:\n\nCompare accuracy with K-NN.\nPerform Dimensionality Reduction:\n\nVisualize datasets in 3-D using PCA.\nPreprocessing Steps\n- Normalization:\n\nDivide each vector by its magnitude.\n- Splitting Dataset:\n\nRandomly select 150 images for training and 20 for testing for each subject.\nResults and Observations\n- Accuracy Comparison:\n\n               - SVM: Highest accuracy (~97.65%).\n               - K-NN: Competitive accuracy (~96.08%).\nGaussianNB: Lower accuracy (~75.69%).\n- Distance Metrics:\n\n            - Euclidean Distance: Effective for face recognition.\n            - Cosine Distance: Less effective for this dataset.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkisaa-fatima%2Fforeground-segmentation-using-kmeans-face-recognization-using-knn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkisaa-fatima%2Fforeground-segmentation-using-kmeans-face-recognization-using-knn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkisaa-fatima%2Fforeground-segmentation-using-kmeans-face-recognization-using-knn/lists"}