c++ - Vignetting correction on RGB image with OpenCV -
first of all: i'm new opencv :-) want perform vignetting correction on 24bit rgb image. used area scan camera line camera , put image 1780x2 px parts complete image 1780x3000 px. because of vignetting, made white reference picture 1780x2 px calculate lut (with correction factor in it) vignetting removal. here code idea:
mat white = imread("white_ref_2l.bmp", 0); mat lut(2, 1780, cv_8uc3, scalar(0)); lut = 255 / white; imwrite("lut_test.bmp", lut*white);
as understood, second last line (hopefully) do, divide 255 every intensity value of every channel , store in lut matrice. want use lut to calculate “real” (not distorted) intensity level of each pixel multiplying every element of src img every element of lut matrice.
obviously not working how want it, memory exception.
can me problem?
edit: i'm using opencv 3.1.0 , solved problem this:
// read white reference image mat white = imread("white_ref_2l_d.bmp", imread_color); white.convertto(white, cv_32fc3); // calculate lut vignetting correction factors mat vlut(2, 1780, cv_32fc3, scalar(0.0f)); divide(240.0f, white, vlut);
of course that's not optimal, read in more white references , calculate mean value optimize.
here's 2 lines white reference, can see shadows @ image borders want correct
when multiply vlut white reference homogenous image result.
thanks, maybe can else ;)
Comments
Post a Comment