This repo has all the image detection methodologies that are commonly used when performing analysis on image datasets and while performing computer vision tasks. It mainly employs the open-cv library in python. Explanation for each file in this repo is given below:
These are implementations of common methodologies along with examples for simple understanding.
These files have all the codes for different types of image operations and feature extraction.
This file has all the input output operations that can be performed on the images.
ChangeDirectory(curr,new)
- Changes the directory that the os is in from curr to newreadImage(file,scale)
- gets the image from storage path file in the scale required. 'scale' can be "gray" for grayscale or "color" for bgrsaveImage(file,image,scale)
- saves the image 'image' at location 'file' in the color 'scale'. 'scale' can be "gray" for grayscale or "color" for bgr.PlotOne(image,scale)
- plots one image 'image' in the color 'scale'. 'scale' can be "gray" for grayscale or "color" for bgr.Plot(images, names, scale, rows, cols, length, breadth)
- Plots multiple images. Employs matplotlib. Here,images
: list of all the images to be plottednames
: list of headings for each imagescale
: list of the colorscale for each image ("gray" or "color")rows
: number of rows (default =10)cols
: number of cols (default = 5)length
: length of each image (default=20)breadth
: breadth of each image(default=20)
Show(images,names)
: Creates a new window with the images. Shows each image in list 'images' in a different window with the 'names' having the list of their titles.
This file contains all the image processing methods that can be used to transform an image and extract only the relevant features from it.
These methods are used to make small changes to the images so as to create a larger dataset for better model performance
Flip(image, orientation)
- Flips the image 'image' either horizontally or vertically (depends on orientation ('horiz' or 'vert'))RandRotate(image)
- rotates the 'image' by a randomly generated angleRandCrop
- Crops the image by a random sizeColorJitter(image)
- Modifies the color of the 'image' by changing the HSV values.GaussianNoise(image)
- Introduces gaussian noise into the 'image'Rescale(image)
- rescales the 'image' to a different sizeTranslation(image)
- Shifts the 'image' in a random direction by a random amountElasticTransformations(image)
- Distorts the 'image' using random displacement fieldsCutout(image)
- randomly masks our rectangular regions in the 'image'Mixup(image1, image2)
- combines two images by blending their pixelsCutmix(image1,image2)
- randomly replaces a portion of 'image1' with a portiaion of 'image2'
Convert(img,curr,new)
- converts the image from current filter to new filter. converts from ('bgr','hsv','rgb') to ('bgr','hsv','gray','rgb')Dilate(image, shape, kernel)
- dilation functionimage
: image to be dilatedshape
: shape to be used for dilation (default=cv2.MORPH_ELLIPSE)kernel
: iterations of dilation (default=10)
Erode(image, shape, kernel)
- erosion functionimage
: image to be erodedshape
: shape to be used for erosion (default=cv2.MORPH_ELLIPSE)kernel
: iterations of erosion (default=10)
CannyEdgeDetection(img,threshold)
: Edge detection method. 'threshold' is a list with 2 values - the lower threshold and the higher threshold. Default is [100,300]HistogramEqualization(image)
: performs histogram equalization on the image. (Converts to greyscale as well)Binary(image)
: performs binary thresholding on the imageBinInverse(img)
: performs inverse binary thresholding on the image 'img'Resize(img, resizepercent)
: resizes or rescales an image by a percentage 'resizepercent'. Default is 0.5