{"id":17841713,"url":"https://github.com/blackcipher101/image-processing","last_synced_at":"2026-04-02T02:54:04.594Z","repository":{"id":119133435,"uuid":"284413828","full_name":"Blackcipher101/Image-processing","owner":"Blackcipher101","description":"This Repository contains all my learnings related to Image processing ","archived":false,"fork":false,"pushed_at":"2020-10-06T17:31:40.000Z","size":12390,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T08:51:26.682Z","etag":null,"topics":["edges","histogram","opencv","pixels"],"latest_commit_sha":null,"homepage":"","language":"Python","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/Blackcipher101.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":"2020-08-02T07:31:01.000Z","updated_at":"2020-10-06T17:31:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"ed59bf42-04c4-48aa-8058-9328072d90ba","html_url":"https://github.com/Blackcipher101/Image-processing","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Blackcipher101/Image-processing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Blackcipher101%2FImage-processing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Blackcipher101%2FImage-processing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Blackcipher101%2FImage-processing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Blackcipher101%2FImage-processing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Blackcipher101","download_url":"https://codeload.github.com/Blackcipher101/Image-processing/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Blackcipher101%2FImage-processing/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269482617,"owners_count":24424404,"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","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["edges","histogram","opencv","pixels"],"created_at":"2024-10-27T21:06:05.257Z","updated_at":"2026-04-02T02:54:04.543Z","avatar_url":"https://github.com/Blackcipher101.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Image-processing\n\nThis repo contains all my learnings in Open-CV \n\n## Basics\n### Image-openning\nThe source code is \u003ca href=\"https://github.com/Blackcipher101/Image-processing/blob/master/Image-open.py\"\u003ehere\u003c/a\u003e\n\nOpencv has function ```cv2.imread(str,channel)``` it takes the arguments of string(filename or path) and the channel 0 corresponds to B/W and 1 corresponds to Color.\nIt can open BMP, JPEG, PNG, PPM, RAS file formats and convert them to ```cv2.Mat``` which is basically a matrix like\n#### B/W\n[ [2 3 4 5 6 7 8]\u003cbr\u003e\n [2 3 4 5 1 8 4]\u003cbr\u003e\n [6 7 8 9 3 4 5] ]\u003cbr\u003e\n#### Color\n[ [[100 34 25] [100 34 25] [100 34 25] [100 34 25]\n [100 34 25] [100 34 25] [100 34 25][100 34 25]\n [100 34 25] [100 34 25] [100 34 25] [100 34 25]]\n\n```cv2.imshow((str),matrix)```  which can open the martrix to image the string is the name of the window \nif the image is to large one can use ```cv2.namedWindow('image', cv.WINDOW_NORMAL)``` it allows you to resize the window\n\n\u003cimg src=\"images/open.png\"\u003e\n\n### Opening Video\n\n```cv2.VideoCapture(str)``` takes path to a video file or 0 for webcam it returns a stream image which can then be read into matrix and displayed using ```cv2.imshow((str),matrix)```\n```cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)``` this converts the channel to B/W (don't get scared newbies what is channel its basically way you define color like RGB) \n\u003cimg src=\"images/video.png\"\u003e\n\n### Creating a video-player with seekbar\n\n  Opencv has a function to create a trackbar you can call a function on change\n  ```python\n  def onChange(trackbarValue):\n    global cap\n    cap.set(1,trackbarValue)\n  ```\n  ```cv2.createTrackbar( 'trackbar', 'frame', 0, length, onChange)```\n  and then you set the cap to a certain value\n  \n  For pausing I basically stopped the cap reading new images\n  So s pause and r runs\n  \u003cimg src=\"images/video-player.png\"\u003e\n  \n  ### Drawing\n  In opencv we can use functions ```cv2.line()``` ```cv2.rectangle()``` ```cv2.circle()``` ```cv2.ellipise()``` ```cv2.polylines()``` \n  for more info on the functions go to \u003ca src=\"https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_gui/py_drawing_functions/py_drawing_functions.html#drawing-functions\"\u003edocs\u003c/a\u003e\n  \n  ## Image processing\n  \n  ### Object-tracking(based on color)\n  So we convert the image to HSV ```cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)``` we changed to HSV because it gives us a range of colors with change of value.\n  We make a image thresholding ```cv2.inRange(hsv, lower_blue, upper_blue)``` with a range and then we \u003cstrong\u003eand with every pixel of both\u003c/strong\u003e ```cv2.bitwise_and()``` it with the image so results in image only with the object\n  \n  \u003cimg src=\"images/object_track.png.png\"\u003e\n  \n  ### Thresholding\n  In Opencv we set a pixel value with respect to another pixel value like\u003cbr\u003e\n  if its less than a certain value it will be set to certain if not then to another\n  ``` if x\u003e125: then x=225 else x=0 ```\n  \n  There are various ones like THRESH_BINARY,THRESH_BINARY_INV,THRESH_TRUNC,THRESH_TOZERO,THRESH_TOZERO_INV\n  \n  \u003cimg src=\"images/thresh.png\"\u003e\n  \n  #### Adaptive thresholding\n  This is a method where we decide the max value based on region of image\n  ```cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,\\cv2.THRESH_BINARY,11,2)```\n            \n   But when we have bimodal images(images with two peaks in a histogram)\n   We \u003cstrong\u003eOtsu,Riddler-Cavldier and Killer IIingworth\u003c/strong\u003emethod.\n   \n    \n   ### Image smoothing\n   \n  Image smoothing is just removal of the edges which results in a blurred image it is done by calling ```cv2.GassuianBlur()```. It allows to reduce the noise in the image \n  but we loose some infomartation in the process Gaussain Blur by taking an average of 5X5 matrix.\n  \n  \u003cimg src=\"images/Otsu.png\"\u003e\n  \n  ### Morphigical Transformatations\n  Its a opertation on we do on binary to erode or diilate images \n  \u003cimg src=\"images/morph.png\"\u003e\n  ### Image gradients\n  We use```cv2.sobel()``` to find image deratives across a direction it gives us the edges in one direction \n  We also get edges in both direction in x-y directation \n  \u003cimg src=\"images/lap.png\"\u003e\n  ### Edge detection\n  We use the function ```cv2.Canny()``` The algorithm is Noise Reduction -\u003e Finding Intensity Gradient of the Image -\u003e Non-maximum Suppression -\u003e Hysteresis Thresholding\n  The basic method is to apply image in gradient in 4 or more direction and the apply suppersion and then find the sure edges.\n  \u003cimg src=\"images/edge.png\"\u003e\n  ### Image Blending\n  This we make images arrays by downscaling the image and also the laplacian \n  then we keep adding the half of both the laplacian and then masking the image with the orginal\n  \u003cimg src=\"images/blend.png\"\u003e\n  \n  ### Image contorors\n  Contours can be explained simply as a curve joining all the continuous points (along the boundary), having same color or intensity. The contours are a useful tool for shape analysis and object detection and recognition.\n  We can use these contours to find moments,area,perimeter and many other informatation.\n  \n  We can apporximate contours to make the processing of informamtaton faster without the loss of important informatation.\n  \u003cimg src=\"images/contours.png\"\u003e\n  \n  ### Draw Histogram\n  You can consider histogram as a graph or plot, which gives you an overall idea about the intensity distribution of an image. It is a plot with pixel values (ranging from 0 to 255, not always) in X-axis and corresponding number of pixels in the image on Y-axis.\n  \u003cimg src=\"image/histogram.png\"\u003e\n  \n  #### Enhanced image\n  The image have a better as it improves the image by adding pixels whose frecquency is less.\n  \u003cimg src=\"images/enhanced.png\"\u003e\n  \n  #### CLAHE \n  It would be better if we could localize the equliztation so CLAHE(Contrast Limited Adaptive Histogram Equalization) was put fowrard \n  \u003cimg src=\"images/Clahe.png\"\u003e\n  #### Backprogagtation\n  We use this to find the object of interst .As we know the certain frequency of pixels we can find it\n  \u003cimg src=\"images/BKpropagate.png\"\u003e\n  \n  \n  ### Template matching \n  We can find certainpart of a image by matching the image to a current template\n  They have various methods but most of the times cv2.TM_CCOEFF works best\n  \u003cimg src=\"images/template.png\"\u003e\n  \n  ### Image segmentation With watershed Algorithm\n  We have to segment the images into its smallest constuient parts\n  Algorithm\n  Threshold-\u003eMorphlogical opertations-\u003eTransforms-\u003eMask\\\n  \u003cimg src=\"images/imgsege.png\"\u003e\n  ### Foregourd Subtractation\n  We use the Grabcut algorithm to remove the backgroung image and also apply mask to improve the accuracy\n  \u003cimg src=\"images/foresub.png\"\u003e\n  \n  ## Fearture detection\n  We will be looking at many algorithms that detect corners\n  \n  ### Harris corner detection\n   It basically finds the difference in intensity for a displacement of (u,v) in all directions.\n   \u003cimg src=\"images/harris.png\"\u003e\n    \n  ### FAST \n  Select a pixel p in the image which is to be identified as an interest point or not. Let its intensity be I_p. -\u003e Select appropriate threshold value t. -\u003e Now the pixel p is a corner if there exists a set of n contiguous pixels in the circle (of 16 pixels) which are all brighter than I_p + t, or all darker than I_p − t. n was chosen to be 12. -\u003e A high-speed test was proposed to exclude a large number of non-corners.\n  \u003cimg src=\"images/fast_true.png\"\u003e\n  \n  ### ORB\n  We have a perfect mixture and also the point its not patented\n  \n  \u003cimg src=\"images/ORB.png\"\u003e\n  ## Video analysis\n  \n  ### Mean shift(object tracking)\n  The intuition behind the meanshift is simple. Consider you have a set of points. (It can be a pixel distribution like histogram backprojection). You are given a   small window ( may be a circle) and you have to move that window to the area of maximum pixel density (or maximum number of points).\n  \n  \u003cimg src=\"images/meanshift1.png\"\u003e\n  \n  ### Optical flow\n  Optical flow is basically tracking the apparent motion on a object and its patterns to do it we use Lucas-Kanade method.We have seen an assumption before, that   all the neighbouring pixels will have similar motion. Lucas-Kanade method takes a 3x3 patch around the point. So all the 9 points have the same motion. We can     find (f_x, f_y, f_t) for these 9 points. So now our problem becomes solving 9 equations with two unknown variables which is over-determined. A better solution    is obtained with least square fit method. We can track features like corners but when we track a songle corner we can draw in air with our fingers :P\n  \n  \u003cimg src=\"images/opticalflow.png\"\u003e\n  ### Background subtracation\n  We subtract the fore ground from the moving objects so we can track them. We can do this using three methods BackgroundSubtractorMOG,BackgroundSubtractorMOG2,BackgroundSubtractorGMG and BackgroundSubtractorGMG proves to be better as it is taken morphological image and reduced noise as a result.\n  \n  \u003cimg src=\"images/backsub.png\"\u003e\n  \n  ## Machine Learning\n  \n  ### K-Nearest Neighbor(kNN)\n  This explains the basic idea of ML where find the most probable answer by measuring its varience from the nearest sure dataset.\n  \u003cimg src=\"images/kNN.png\"\u003e\n  \n  ### OCR\n  We uses kNN and pre given dataset to train and test the for testing digit detection for explantation it works \u003ca href=\"https://www.youtube.com/watch?v=aircAruvnKk\"\u003ehere\u003c/a\u003e\n  \n  ###  Quantizing Colors\n  We can quantize colors if want to drop the computation but want to still carry forward the color data. We quantize the colors using kNN clustering.\n  \n  \u003cimg src=\"images/quantized.png\"\u003e\n  \n  ### Face detection \n  \n  \u003cimg src=\"images/face.png\"\u003e\n  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblackcipher101%2Fimage-processing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblackcipher101%2Fimage-processing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblackcipher101%2Fimage-processing/lists"}