CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
BIMEF: A Bio-Inspired Multi-Exposure Fusion Framework for Low-light Image Enhancement #2448
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
Conversation
return (T(0) < val) - (val < T(0)); | ||
} | ||
|
||
double minimize_scalar_bounded(const Mat_<float>& I, double begin, double end, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code ported from here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for your effort!
} | ||
|
||
template <class numeric_t> | ||
Eigen::SparseMatrix<numeric_t> spdiags(const Eigen::Matrix<numeric_t,-1,-1> &B, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spdiags
function is taken from here.
Could you comment on the input parameters of the algorithm?
|
05a17c2
to
adfd9e5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for great contribution!
Please ignore "Docs" builder warning (it is about size of opencv_extra
patch - it looks acceptable).
* @param a a-parameter in the Camera Response Function (CRF). | ||
* @param b b-parameter in the Camera Response Function (CRF). | ||
*/ | ||
CV_EXPORTS_W void BIMEF(const Mat& input, Mat& output, float mu=0.5f, float *k=NULL, float a=-0.3293f, float b=1.1258f); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you check that bindings can handle "k" pointer parameter properly?
It would be great to add Python test here: misc/python/test/test_intensity_transform_bimef.py
(use self.get_sample()
to fetch test images)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated with:
CV_EXPORTS_W void BIMEF(InputArray input, OutputArray output, float mu=0.5f, float a=-0.3293f, float b=1.1258f);
CV_EXPORTS_AS(BIMEF2) void BIMEF(InputArray input, OutputArray output, float k, float mu, float a, float b);
filenames = ['P1000205_resize', 'P1010676_resize', 'P1010815_resize'] | ||
|
||
for f in filenames: | ||
img = self.get_sample('cv/intensity_transform/BIMEF/{}.png'.format(f)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an observation.
This is different from C++ cvtest::findDataFile()
where cv/
. is not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right.
C++ test specifies prefix for its testdata globally here.
self.assertLessEqual(RMSE, max_RMSE_threshold) | ||
print('BIMEF RMSE:', RMSE) | ||
|
||
except cv.Error.StsNotImplemented as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how to handle when Eigen is not available (#ifdef HAVE_EIGEN
) in Python.
So I just catch the exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cv.Error.StsNotImplemented
is not an exception (it is OpenCV error code), so it can't be catched here.
Please consider removing "try-catch" here and add snippet above (after class
line 12):
class intensity_transform_test(NewOpenCVTests):
+ def setUp(self):
+ super(intensity_transform_test, self).setUp()
+ try:
+ result_ = cv.intensity_transform.BIMEF(None)
+ except cv.error as e:
+ if e.code == cv.Error.StsNotImplemented:
+ self.skipTest('BIMEF is not implemented (missing Eigen dependency)')
I did not find instructions about how to run Python tests in OpenCV. It would be great to update this page. What I did:
Also, an useful feature would be the possibility to filter the tests, similarly to I have compared the results between the original code in Matlab with this Python implementation and with the current OpenCV implementation.
Anyway, for a first integration I guess it is fine. I will try to look at it in the future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for update and python test!
Python test with filtering can be launched from the build directory in this way:
OPENCV_PYTEST_FILTER=test_intensity_transform_bimef ./setup_vars.sh python3 ${OpenCV_SRC_DIR}/modules/python/test/test.py -v
self.assertLessEqual(RMSE, max_RMSE_threshold) | ||
print('BIMEF RMSE:', RMSE) | ||
|
||
except cv.Error.StsNotImplemented as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cv.Error.StsNotImplemented
is not an exception (it is OpenCV error code), so it can't be catched here.
Please consider removing "try-catch" here and add snippet above (after class
line 12):
class intensity_transform_test(NewOpenCVTests):
+ def setUp(self):
+ super(intensity_transform_test, self).setUp()
+ try:
+ result_ = cv.intensity_transform.BIMEF(None)
+ except cv.error as e:
+ if e.code == cv.Error.StsNotImplemented:
+ self.skipTest('BIMEF is not implemented (missing Eigen dependency)')
…ht Image Enhancement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done! Thank you 👍
Merge with extra: opencv/opencv_extra#737
@baidut
I have ported the BIMEF Matlab code to C++. I have used this repository as reference, the license is MIT.
Feel free to comment if you do not agree with this porting.
First test shows that it is slower than the original Matlab code, most likely due to the computation time of the Eigen Sparse Linear Solver.
Left: original image
Middle: gamma correction with
0.4
valueRight: BIMEF
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.