split into many files
add better outlier rejection add normalization add background removal
This commit is contained in:
29
normalize.h
Normal file
29
normalize.h
Normal file
@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
#include <opencv2/core/ocl.hpp>
|
||||
#include <opencv2/imgproc.hpp>
|
||||
#include <stdint.h>
|
||||
|
||||
inline bool normalize(cv::Mat& image, const cv::Mat& referance)
|
||||
{
|
||||
cv::Mat labReferance;
|
||||
cv::cvtColor(referance, labReferance, cv::COLOR_BGR2Lab);
|
||||
std::vector<cv::Mat> labPlanesRef(3);
|
||||
cv::split(labReferance, labPlanesRef);
|
||||
|
||||
cv::Scalar mean = cv::mean(labPlanesRef[0]);
|
||||
labPlanesRef[0].convertTo(labPlanesRef[0], CV_16SC1);
|
||||
|
||||
labPlanesRef[0] = labPlanesRef[0] - cv::Scalar(mean);
|
||||
|
||||
|
||||
cv::Mat labImage;
|
||||
cv::cvtColor(image, labImage, cv::COLOR_BGR2Lab);
|
||||
|
||||
std::vector<cv::Mat> labPlanes(3);
|
||||
cv::split(labImage, labPlanes);
|
||||
|
||||
cv::add(labPlanes[0], labPlanesRef[0], labPlanes[0], cv::noArray(), CV_8UC1);
|
||||
cv::merge(labPlanes, labImage);
|
||||
cv::cvtColor(labImage, image, cv::COLOR_Lab2BGR);
|
||||
return true;
|
||||
}
|
Reference in New Issue
Block a user