I have an Image (banknotes) as a dataset that is under UV Light. I want to image process it back to RGB again in order to detect which banknote is it (if it is 20, 50, 100 and so on bill)
Since this project will be used in a hardware I dont want to turn on and off the UV lights to attain its efficiency and speed.
I have created a code that will convert its contrast, warmth and tint.
def change_contrast(img, level):
factor = (259 * (level + 255)) / (255 * (259 - level))
def contrast(c):
return 128 + factor * (c - 128)
return img.point(contrast)
def adjust_warmth(image, warmth_factor):
b, g, r = cv2.split(image)
r = cv2.add(r, int(warmth_factor)) # Increase red channel
b = cv2.subtract(b, int(warmth_factor)) # Decrease blue channel
warmed_image = cv2.merge([b, g, r])
return np.clip(warmed_image, 0, 255).astype(np.uint8)
def adjust_tint(image, tint_factor):
tinted_image = np.zeros_like(image)
# Increase or decrease each channel
tinted_image[:, :, 0] = cv2.add(image[:, :, 0], int(tint_factor)) # Blue channel
tinted_image[:, :, 1] = cv2.add(image[:, :, 1], int(tint_factor)) # Green channel
tinted_image[:, :, 2] = cv2.add(image[:, :, 2], int(tint_factor)) # Red channel
return np.clip(tinted_image, 0, 255).astype(np.uint8)
This are the sample I've made. But its not enough to attain the original color of it.
new_image = change_contrast(Image.open('20-f.jpg'), 50)
new_image = new_image.rotate(90)
new_image_np = np.array(new_image)
img3_warmth = adjust_warmth(new_image_np, -25)
img3_tint = adjust_tint(img3_warmth, -35)
fig = plt.figure(figsize=(12,12))
ax = fig.add_subplot(111)
ax.imshow(img3_tint)
plt.show()
This is the image i want to attain.
Converting UV to RGB is physically impossible.
UV is invisible to the human eye. It's also invisible to most cameras, which have a filter for visible light (or R,G,B spectra anyway) so their images look like something we're used to.
We "see" it because some materials absorb UV and re-emit it as other wavelengths, which we can see.
You illuminated your banknote with UV-spectrum light. You have only obtained information on what the material emits when excited by UV. You have gained no information on what parts of the visible light spectrum the material would reflect.
There is no way to infer an object's appearance under lighting with some spectrum, if you only have images of the object illuminated under other spectra.
That's the best answer you can expect, given the question and constraints.
If you wanted to merely tell the value of the banknote, you can do that under UV light just fine.