Computer Vision module codes in MATLAB/Octave.
To process Image 1, run the code 'processTextFile.m'. To process Image 2, run the code 'processPngFile.m'.
Image 1 (charact1.txt) is a 64x64 image. Image 2 (charact2.bmp) is a bitmap image of a label on a microschip. For each image, the following tasks need to be performed.
- Display the original image.
- Create a binary image using thresholding.
- Segment the original image to separate and identify the different characters.
- Rotate the characters in the image avout their own respective centroids by 90 degrees clockwise.
- Rotate the characters in the image from step 4 about their own respective centroids by 35 degrees counterclockwise.
- Determine the outline(s) of characters of the image from Step 3.
- Determine a one-pixel thin image of the characters from Step 3.
- Scale and display the characters of Image 1 in one line with the sequence 1A2B3C.
- Scale and display the characters of Image 2 in one line with the sequence 7M2HD44780A00.
In order to develop a better understanding, all the algorithms have been implemented using the first principle calculations using loops. Due to this the run-time is much longer (especially in Octave). However, the idea is to understand how the basic image processing algorithms work.
For loading images into the system memory, inbuilt functions fileread and imread are used. In addition to this bwlabel is used to label different connected components in the segmented binary image. The same functions are available in Octave package Image.
The detais of implemented algorithms can be found here. These algorithms are implemented -
- binaryMorphology - Perform morphological operations (erode, dilate, open, close) on binary images.
- boundary - Find the boundary of connected components in a binary image.
- histogram - Calculate the histogram of the grayscale image.
- histogramEqualize - Enhance the contrast of the grayscale image using histogram equalization.
- imageRotate - Roate the grayscale image. Nearest neighbor and bilinear interpolation methods are implemented.
- imageScale - Scale up or down an image. Nearest neighbor and bilinear interpolation methods are implemented.
- label - Need to fix this.
- negativeTransform - Invert the intensity value of each pixel.
- particleAreaFilter - Filters out connected components in a binary image whose area is not in a certain range.
- regionProps - Find out the bounding box, area, centroid, width, and height of all connected components in a binary image.
- skeleton - Skeletonize/thin the binary input image.
- stretchContrast - Stretch the contrast of a grayscale image between 0-255.
- textTOascii - convert the text character to its corresponing ASCII value.
- threshold - Global thresholding of a grayscale image. Constant, mean, median, Otsu, and maxentropy thresholding methods are implemented.
- thresholdAdaptive - Local thresholding of a grayscale image. Mean thresholding method is implemented.
The codes have been tested on Windows 10 (64-bit), Linux Mint Cinnamon 19.2 (64-bit), and Raspbian Buster (32-bit, Octave only). The following programs need to be installed.
- MATLAB with image processing toolbox
- Octave with image package.
- TODO - implement particle labelling algorithm to label different connected components in a binary image.