Re: [sane-devel] Partial success using Iriscan Express 3

2023-09-20 Thread Stephane Louise
Hi,

Le mar. 19 sept. 2023 à 21:15, Ralph Little  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')


Re: [sane-devel] Partial success using Iriscan Express 3

2023-09-19 Thread Ralph Little
Hi,
Thanks you for your report!

On Tue, Sep 19, 2023 at 2:34 AM Stephane Louise 
wrote:

> Hello,
>
> I wanted to report a partial success using Iriscan Express 3 scanner with
> sane (it is an oldy, but it was given to me so why not give it a try).
> For that, I probed the scanner using sane-find-scanner and scanimage -L,
> and was pretty confident that it was a gt6816 based scanner. Therefore I
> overrode the detection of the scanner to iriscan-express-2, in gt68xx.conf
> and it kind-of worked.
>
> The results: the commands are accurately given to the scanner, and it can
> scan in its highest resolution (600dpi) without crashing or endomaging the
> hardware. The main caveat is the fact that the output file is a horizontal
> gradient of the picture which is "not optimal" (looks like e.g. a Prewitt
> filter applied to the output). N.B: there are miss-alignments with lower
> resolutions also but for me it is still minor as long as I could make the
> native resolution work.
>

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.

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.

Cheers,
Ralph