Hi,

Le mar. 19 sept. 2023 à 21:15, Ralph Little <[email protected]> a écrit :

> It would be cool to see some samples of that. It might be something that
> is easy to fix.
> Even better would be to create an issue on our GitLab backends page where
> the information you have supplied could be kept and progress tracked.
>
> Done. I hope this is the correct place. I had some issues with formatting
and # characters, so, something got lost in the post on gitlab. Hopefully
the portions of images are relevant.


> If you don't feel happy to do that then you could send some sample images
> to me personally and I will open the issue there. It also means that it
> doesn't get forgotten.
>
> Many thanks.

In the meantime, I played with python and openCV. I could make something
recognizable at least with the attached script. Nonetheless, integrating a
gradient is usually a bad idea because it is too sensitive to noise.

Cheers,

Stephane Louise
#import cv2, numpy and matplotlib libraries
import cv2
import numpy as np
import matplotlib.pyplot as plt
img=cv2.imread("color-ex.png")
#img=cv2.imread("partial.png")
#img= cv2.imread("extract.png")
print("Image size:",len(img),";",len(img[0]))
img2= img.copy()
mb=0
mg=0
mr=0
nb=0
for xi in img[0]:
	mb+= xi[0]
	mg+= xi[1]
	mr+= xi[2]
	nb+=1
print("Rm=",mr/nb," Gm=",mg/nb, "Bm=",mb/nb)
# means for each color channel
meanr= int(mr/nb)
meang= int(mg/nb)
meanb= int(mb/nb)
for xi in range(len(img)):
	curvalr= 0
	curvalg= 0
	curvalb= 0
	nb=0
	for yj in range(len(img[0])):
		pixel= img[xi,yj]
		# use the means to find the signed gradient value (don't ask about -0.75, it just works better experimentally, that's all)
		deltb= pixel[0]-meanb-0.75
		deltg= pixel[1]-meang-0.75
		deltr= pixel[2]-meanr-0.75
		# blue val managemen (integrate)t
		curvalb+= deltb
		if curvalb<0: 
			curvalb=0
		if curvalb>255:
			curvalb=255
		# green val management (integrate)
		curvalg+= deltg
		if curvalg<0: 
			curvalg=0
		if curvalg>255:
			curvalg=255
		# red val management (integrate)
		curvalr+= deltr
		if curvalr<0: 
			curvalr=0
		if curvalr>255:
			curvalr=255
		# some random correction of brightness to improve the output
		r= int(curvalr+30) if curvalr<225 else int(curvalr)
		g= int(curvalg+30) if curvalg<225 else int(curvalg)
		b= int(curvalb+30) if curvalb<225 else int(curvalb)
		# I don't know why the color channels are switched between red and blue
		img2[xi,yj]= (r, g, b)

# show result		
plt.imshow(img2)
 
#hold the window
plt.waitforbuttonpress()
plt.close('all')

Reply via email to