In this project we have implemented some Image Processing Techniques implemented from scratch using C++, we have implemented our Techniques in this readme in lenna image for more illustration.
- Visual Studio C++ Workload
- OpenCV
- CMake
- Configure project.
N.b use only after cloning or changing CMakeLists.txt.
$ cmake . -B ./build
- Build the executable
$ cmake --build ./build/
- The executable will be in the build/Debug/ folder
$ build/Debug/cv-project-1.exe
- Clean the build folder (Optional)
$ cmake --build ./build/ --target clean
## 1. Adding Noise To Image
Three types of noise are implemented in this project: Uniform, Gaussian, and Salt & Pepper noise
img::Image add_noise(img::Image image , std::string type ,uchar noise_factor)
image
: the image on which the should be added, it should be of class img::Image which is implemented in this project.
type
: the type of noise you want to add, there are three types you must write any one of them "Gaussian", "Uniform" , and "Salt".
noise_factor
: It's the ratio of the noise in the image.
## 2. Image Filtering
Three types of noise are implemented in this project: Median, Mean, and Gaussian filters.
img::Image noise_filter(img::Image source,int size, std::string type ,double std=1)
image
: the image on which the should be added, it should be of calse img::Image
type
: the type of noise filter you want to apply, there are three types you must write any one of them "Gaussian", "Mean" , and "Median".
std
: It's the standard deviation of the gaussian kernal, it has a default value equals 1, It should be used only when using Gaussian filter unless it will be useless.
The following examples for filttering the Salt & Pepper noise implemented in this project.
Three types of detection are implemented in this project: Sobel, Prewitt, and Roberts. sobel :
Image sobel(const Image &img, bool dx = true, bool dy = true)
Image prewitt(const Image &img, bool dx = true, bool dy = true)
Image roberts(const Image &img, bool dx = true, bool dy = true)
cvector<double> canny(const Image &img, double threshold1, double threshold2)
Image
: Image
dx
: if you want to detect the horizontal edges
dy
: if you want to detect the vertical edges
void Plot_Histogram(Image img,string image_type)
void plot_Distribution_curve(Image img,string image_type)
image
: the image you want to plot its histogram and distribution curve, it should be of class img::Image which is implemented in this project.
image_type
: the type of image you entered "grayscale" or "color"
equalization has multiple steps of pipelining such as histogram loop, accumulation loop and mapping loop. this function is returning Image type so it can be used in further steps. the whole function is implemented in image.cpp
img: the image which will be equalized. (image type)
Normalization is only dependent on few parameters which are min new value, max new value and the image itself.
by the given equation -> (newrange * (value - oldmin) / oldrange) + newmin
we can get the new value for a pixel
We put the equation in utils.cpp file, while the whole normalization function were put in the mentioned image class.
img: the image which will be normalized. (image type) min: minimum percentage as this function is dynamic (not restricted to specific number). (0 - 100) max: max percentage as this function is dynamic (not restricted to specific number). (0 - 100)
normalized between 0 and 20 percentage
normalized between 80 and 100 percentage
Image globalThreshold(Image &img, float threshold, float mx_value, t_types thresholdType)
for global Thresholding
img
: the image that you want to threshold
threshold
: threshold value
mx_value
: the value is set in place of pixel
thresholdType
: threshold type can be
THRESH_BIN
if the value is greater than threshold so the maximum is set to the pixel or THRESH_BIN_INV
if the value is greater than threshold so 0 is set to the pixel
Image localThreshold(Image &img, float mx_value, t_types thresholdType)
for local Thresholding it uses an adaptive gaussian thresholding algorithm
img
: the image that you want to threshold
threshold
: threshold value
mx_value
: the value is set in place of pixel
thresholdType
: threshold type can be
THRESH_BIN
if the value is greater than
threshold so the maximum is set to the pixel or THRESH_BIN_INV
if the value is greater than threshold so 0 is set to the pixel
img::convert(img::Image source, "bgr", "gray");
void Plot_Histogram(Image img,string image_type)
void Plot_Cumulative(Image img,string image_type)
Image PassFilter(Image &img, float freq_threshold,p_types pass_type)
to filter the frequency domain
img
: the image that you want to filter
freq_threshold
: frequency threshold value
pass_type
: pass type can be
LOW_PASS_FILTER
it removes all the values that is above the frequency threshold , HIGH_PASS_FILTER
it removes all the values that is below the frequency threshold
Image hybridImages(Image &img1, Image &img2)
it takes two images and merge them in one image using the low frequency of one image and the high frequency of the other image