Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added comments to operators Yee03, Chen05 and Mantiuk08 #131

Merged
merged 49 commits into from
Jan 21, 2025
Merged
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
48979cc
creation of Chen05 and block partition process implemented
Matthewlele Nov 14, 2022
da00aa9
Merge branch 'cadik:master' into master
Matthewlele Nov 28, 2022
267a871
creating of block's signatures
Matthewlele Dec 11, 2022
c119161
Merge branch 'master' of github.com:Matthewlele/TMS
Matthewlele Dec 11, 2022
2a1d383
creating EMD function
Matthewlele Dec 11, 2022
60f0971
finding neighbouring blocks implementation
Matthewlele Dec 16, 2022
3092d5f
fixed finding neighbours
Matthewlele Dec 16, 2022
bb5dcd0
begininng of implementation of the luminance-driven grouping algo
Matthewlele Dec 17, 2022
4627928
creation of updateRegionSignature function , need to find problem wit…
Matthewlele Dec 20, 2022
1be2d57
billateral filter algo, fixed canny image loading
Matthewlele Dec 27, 2022
594c5c8
delete some unnecesarry stuff
Matthewlele Dec 27, 2022
142d1db
canny edge detector update
Matthewlele Dec 29, 2022
e8b8f51
small update
Matthewlele Jan 3, 2023
6961c9b
changes in calculating signatures
Matthewlele Jan 6, 2023
65a036b
usage of new EMD function
Matthewlele Jan 7, 2023
d08cee8
fixing bugs
Matthewlele Feb 12, 2023
89e470a
tone mapping algorithms
Matthewlele Mar 14, 2023
04d5e5b
small updates
Matthewlele Mar 16, 2023
0dd67a5
update
Matthewlele Mar 20, 2023
43da234
update
Matthewlele Mar 20, 2023
9673e53
functions for hvs
Matthewlele Mar 23, 2023
ace43e5
update
Matthewlele Mar 26, 2023
944ce38
updates
Matthewlele Mar 30, 2023
58c41d6
changes still to debug
Matthewlele Mar 31, 2023
b2310e8
fixed tone curve calculation
Matthewlele Apr 3, 2023
8fec645
fixed tone curve calculation
Matthewlele Apr 3, 2023
8ab5bba
fixed tone curve calculation
Matthewlele Apr 3, 2023
dc29155
fix
Matthewlele Apr 3, 2023
1104526
modifications
Matthewlele Apr 8, 2023
f611025
updates
Matthewlele Apr 16, 2023
98cf7f2
updates
Matthewlele Apr 17, 2023
67cb299
added comments
Matthewlele Apr 18, 2023
44c26d4
added comments
Matthewlele Apr 23, 2023
2da520e
update
Matthewlele Apr 23, 2023
4316b71
added comments to implemented methods
Matthewlele May 31, 2023
a209f77
implementation of Ancuti10, separation and maps are probably correct,…
Matthewlele Nov 2, 2024
8fb773c
fixed Ancuti10 still missing comments and maybe some adjucements
Matthewlele Nov 9, 2024
2e9c689
creation of method Song14
Matthewlele Nov 17, 2024
6fada3b
added headers and some comments
Matthewlele Nov 22, 2024
85bb1fb
fixed typo
Matthewlele Nov 24, 2024
ec2571a
started own implementation of Tao method, some functionality is imple…
Matthewlele Dec 1, 2024
98003f4
fixed proximity calculation, still need some fixes in the classifier …
Matthewlele Dec 8, 2024
8f07c05
created implementation of MDP, still needing LDP
Matthewlele Dec 12, 2024
f0bcad8
functioning LDP, still need some fixing on MDP and HDP
Dec 29, 2024
0881911
LPD and HPD seems to be working fine now (maybe will need some tuning…
Dec 30, 2024
6188500
little clean up and some comments, will add more later
Matthewlele Jan 14, 2025
a9b9efa
some minor cleanup and added comments
Matthewlele Jan 14, 2025
71ab398
cleaning up and adding some comments
Matthewlele Jan 15, 2025
ea7b235
Merge branch 'master' into master
cadik Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
created implementation of MDP, still needing LDP
Matthewlele committed Dec 12, 2024
commit 8f07c05e27f65a11afafd4632a9a33ca8236212c
53 changes: 53 additions & 0 deletions TMOTao18/TMOTao18.cpp
Original file line number Diff line number Diff line change
@@ -128,6 +128,58 @@ void TMOTao18::computeProximity(const cv::Mat& currentFrame, const cv::Mat& prev
deltaC = sqrt((deltaA * deltaA + deltaB * deltaB) / 2.0);
}

cv::Mat TMOTao18::applyMPD(const cv::Mat& currentFrame, const cv::Mat& previousFrame, const cv::Mat& previousGray)
{
cv::Mat currLab, prevLab, prevLabGray;
cv::cvtColor(currentFrame, currLab, cv::COLOR_BGR2Lab);
cv::cvtColor(previousFrame, prevLab, cv::COLOR_BGR2Lab);
cv::cvtColor(previousGray, prevLabGray, cv::COLOR_BGR2Lab);

cv::Mat flow;
cv::calcOpticalFlowFarneback(previousGray, currLab, flow, 0.5, 3, 15, 3, 5, 1.2, 0);

//initialize Ci with the current frame
cv::Mat Ci = currLab.clone();
const double sigma_p = 1.0; //noise variance in frame transition
const double sigma_t = 1.0; //noise variance in frame transition
const double alpha = 0.1; //step length for gradient ascent
const int maxIterations = 10; //maximum number of iterations
for (int iter = 0; iter < maxIterations; iter++) {
cv::Mat Ci_new = Ci.clone();

for (int y = 0; y < currentFrame.rows; y++) {
for (int x = 0; x < currentFrame.cols; x++) {
cv::Point2f flowAt = flow.at<cv::Point2f>(y, x);
int newX = cv::borderInterpolate(x + flowAt.x, currentFrame.cols, cv::BORDER_REFLECT_101);
int newY = cv::borderInterpolate(y + flowAt.y, currentFrame.rows, cv::BORDER_REFLECT_101);

//calculate Mi using the L2-norm
cv::Vec3d diff = currLab.at<cv::Vec3b>(y, x) - prevLab.at<cv::Vec3b>(newY, newX);
double Mi = cv::norm(diff, cv::NORM_L2);

//calculate the gradient of P(Ci)
cv::Vec3d gradP_Ci = - (Ci.at<cv::Vec3b>(y, x) - prevLabGray.at<cv::Vec3b>(y, x)) / (sigma_p * sigma_p)
- (1 / Mi) * (Ci.at<cv::Vec3b>(y, x) - prevLabGray.at<cv::Vec3b>(newY, newX)) / (sigma_t * sigma_t);

//update Ci using gradient ascent
for (int k = 0; k < 3; k++) {
Ci_new.at<cv::Vec3b>(y, x)[k] = cv::saturate_cast<uchar>(Ci.at<cv::Vec3b>(y, x)[k] + alpha * gradP_Ci[k]);
}
}
}

// Check for convergence (optional)
if (cv::norm(Ci_new - Ci) < 1e-3) {
break;
}

Ci = Ci_new;
}
cv::Mat result = 0.5 * prevLabGray + 0.5 * Ci;
return result;

}

cv::Mat TMOTao18::applyHPD(const cv::Mat& currentFrame, const cv::Mat& previousFrame, const cv::Mat& previousGray, double phi)
{
//convert rgb frames to Lab color space
@@ -166,6 +218,7 @@ cv::Mat TMOTao18::applyHPD(const cv::Mat& currentFrame, const cv::Mat& previousF
differentialRefinement.at<double>(y, x) = phi * chromaDiff + (1 - phi) * luminanceDiff;
}
}
return differentialRefinement;
}

std::vector<int> TMOTao18::classify(const std::vector<cv::Vec2f>& proximityValues)
1 change: 1 addition & 0 deletions TMOTao18/TMOTao18.h
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ class TMOTao18 : public TMOv
double logLikelihood(const std::vector<cv::Vec2f>& dataPoints, const std::vector<int>& clusters, const std::vector<cv::Vec2f>& means, const std::vector<cv::Mat>& covariances, const std::vector<double>& priors);
bool hasConverged(double L, double prevL, double threshold);
cv::Mat applyHPD(const cv::Mat& currentFrame, const cv::Mat& previousFrame, const cv::Mat& previousGray, double phi);
cv::Mat applyMPD(const cv::Mat& currentFrame, const cv::Mat& previousFrame, const cv::Mat& previousGray);

protected:
TMODouble dParameter;