Hello guys,
i have a problem with a projekt i´m working on. I want to profile the raspberry pi camera and later do some other stuff with it.
However, my LED´s are illuminating the picture very unevenly, so i have to adjust for it. So the first step i have to do is convert the picture from BGR to LAB and correct the lightness.
Here comes the problem:
I have 2 pictures. Picture A with the profiling Chart and Picture B, which is a white sheet of paper in the exact same position.
My plan was to find the minimum l-channel value in the white picture, subtract this value from the normal lightness of the white picture and then subtract that from the lightness of the Profiling chart.
At the end merge the channels back together and convert back to BGR.
This way the uneven illumination shouldn´t disturb the colors of the chart and the profiling process.
My Script:
import cv2
-----Reading the image--
Img1 = cv2.imread('Test123_Weiss.jpg', 1) Img2 = cv2.imread('Test123.jpg', 1) imgA = cv2.resize(Img1, (800, 600)) imgB = cv2.resize(Img2, (800, 600)) cv2.imshow("img",imgB)
-----Converting image to LAB Color model--
labA= cv2.cvtColor(imgA, cv2.COLOR_BGR2LAB) labB= cv2.cvtColor(imgB, cv2.COLOR_BGR2LAB)
cv2.imshow("lab",lab)
-----Splitting the LAB image to different channels--
lA, aA, bA = cv2.split(labA) lB, aB, bB = cv2.split(labB)
-----Find L-channel minimum--
(minVal, maxVal, minLoc, maxLoc) = cv2.minMaxLoc(lA)
-----Subtract difference of L-channels--
lv = cv2.subtract(lA,minVal) lc = cv2.subtract(lB,lv)
-----Merge the enhanced L-channel with the a and b channel--
limg = cv2.merge((lc,aB,bB))
-----Converting image from LAB Color model to RGB model--
final = cv2.cvtColor(limg, cv2.COLOR_LAB2BGR) cv2.imshow('final', final)
cv2.imwrite('lightness.jpg' ,final)
cv2.waitKey(0)
_____END_____
MAybe somebody has an idea how to make this work?