Daniel Reetz, the founder of the DIY Book Scanner community, has recently started making videos of prototyping and shop tips. If you are tinkering with a book scanner (or any other project) in your home shop, these tips will come in handy. https://www.youtube.com/channel/UCn0gq8 ... g_8K1nfInQ

IXUS 160 Focal Plane

Everything camera related. Includes triggers, batteries, power supplies, flatbeds and sheet-feeding scanners, too.
Post Reply
hacki
Posts: 4
Joined: 01 Apr 2018, 19:05
Number of books owned: 0
Country: Germany

IXUS 160 Focal Plane

Post by hacki » 02 Apr 2018, 17:37

Hi there,


I have a bit of an issue with my two IXUS 160.


I'm using some undocumented deep firmware commands in CHDK to directly position the focussing motor.
That way i can reliably and very precisely set the focus.


While trying to find out the best settings i noticed that the focal plane does not appear to be parallel to the imaging plane.
I aligned to camera perpendicular to the platen by aiming it directly at the reflection of the lens in the platen.
An image of a gridded paper seems to agree that the alignment is spot on.

See the two attached images. Notice how in one image the top is sharp and the buttom is blurry and vice versa?

If the focal plane was parallel to the imaging plane i imagine thered be one setting where everything was in focus with evenly decreasing sharpness towards the edges.


In any case - did anyone here experience this as well, and found a solution? Are my cameras defective?


What works reasonably well for me is taking 3 consecutive images with different focal points and then using a focus stacking software to create an evenly sharp image.
Unfortunately that slows everything down by orders of magnitudes, having to wait for 3 images to be taken, and then processing them in a focus stacker.
Attachments
1510_PAPER.jpg
1490_PAPER.jpg

duerig
Posts: 368
Joined: 01 Jun 2014, 17:04
Number of books owned: 1000
Country: United States of America

Re: IXUS 160 Focal Plane

Post by duerig » 02 Apr 2018, 22:26

You've hit one of the fundamental limitations in the possible quality provided by cheap point and shoot cameras. The focus on every camera is based on the distance of the target from the lens. On a properly aligned book page, the distance between the center of the page and the lens will always be less than the distance between the corner of the page and the lens.

There are several possible ways to deal with this. You have hit upon one of them.

(1) Accept that the corners will always be slightly blurrier (lost quality at corners)
(2) Focus Stacking might yield the best quality, but as you see it takes more time per photo.
(3) If you zoom out, the 'blurrier corners' will no longer be page material and are cropped out. The cost of this method is lower DPI. But in many cases this is a good trade-off. For medium-sized books, you can capture them at 300 DPI and still have plenty of border to crop.
(4) Buy a higher end camera. DSLRs and mirrorless cameras have an aperture setting which among other things changes the depth of field (minimum and maximum distance where things are still in focus). So this gives you a knob you can use to have sharp corners and a sharp center even though they are different distances from the lens.

There may be some other clever solution or workaround that I don't know about. But your cameras aren't defective. It is just the limits of point and shoot cameras in general.

-Jonathon Duerig

hacki
Posts: 4
Joined: 01 Apr 2018, 19:05
Number of books owned: 0
Country: Germany

Re: IXUS 160 Focal Plane

Post by hacki » 03 Apr 2018, 06:41

I'm aware that sharpness decreases towards the Edges. I know what curved field and flat field lenses are. Thats not whats happening here.

It behaves as if the page is angled towards the camera significantly. When i move the focus from infinity towards the camera, first the bottom of the image gets in focus while the top is still out of focus. Moving the focus closer to the camera, the area of sharpness moves across the page until the top is in focus and the bottom is out of focus again.
Well, i attached two annotated pictures of an actual bookpage. Maybe that'll make it clearer what i mean:
1480_L.jpg
1510_L.jpg

I'd expect for an equally increasing and decreasing sharpness across the page when stepping through the focus positions, with the sharpest areas in the center of the frame. Not ... this.



But the optics on that camera model appear to be somewhat off kilter anyways, as it does not look like the optical axis is actually in the center of the frame, but slightly offset to the bottom right. At least comparing pictures at zero zoom and full zoom reveals that the full zoom is not a crop of the dead center of the image. However that works is a mystery to me.

duerig
Posts: 368
Joined: 01 Jun 2014, 17:04
Number of books owned: 1000
Country: United States of America

Re: IXUS 160 Focal Plane

Post by duerig » 03 Apr 2018, 17:33

I have not seen this pattern with the focal plane before. I have seen the slight offset of the center when zooming in/out but that seemed innocuous.

So it seems like there are two possibilities. One is that your camera has an unusual defect. The other is that your camera isn't actually aligned with the platen.

The alignment option is certainly the cheaper of the two to fix. So I'd recommend double-checking that first. It could be either that the camera was bumped out of alignment after you had carefully aligned it. Or that it wasn't aligned as well as it seemed.

When I do alignment, I use a small mirror with a painted crosshair on its face. The mirror is taped to the center of the platen. It is on top of the platen to hopefully avoid any distortions that might be induced by the glass.

You should enable a crosshairs overlay on the camera itself, line those crosshairs with the ones on the mirror, and then ensure that both sets of crosshairs are centered on the reflected image of the lens.

But if you already followed the above procedure and find that it is properly aligned, then it may just be a quirk in the camera itself and you will need a replacement.

-Jonathon Duerig

BillGill
Posts: 98
Joined: 18 Dec 2016, 17:13
E-book readers owned: Calibre, FBReader
Number of books owned: 7000
Country: USA

Re: IXUS 160 Focal Plane

Post by BillGill » 04 Apr 2018, 09:17

This may not have anything to do with your problem, but I had a problem with my Elph 160 not focusing properly when I had it zoomed in with the camera too close to the platen. For various zoom ratios there is a minimum distance that the camera has to be from the platen for it to focus properly. The tighter the zoom the further away from the platen you have to be. You might try checking on that.

Bill

hacki
Posts: 4
Joined: 01 Apr 2018, 19:05
Number of books owned: 0
Country: Germany

Re: IXUS 160 Focal Plane

Post by hacki » 04 Apr 2018, 13:32

Alignment like this:
chdkptp_20180404_153114.jpg
chdkptp_20180404_153114.jpg (55.85 KiB) Viewed 748 times

The Autofocus on those cameras is kind of crappy anyways, which is why i'm using some direct firmware calls to position the focus servo exactly where i want it.

Works like this:

- Check "Enable LUA Native Calls?" in the CHDK misc. settings on the camera

- Execute this code on the camera or via chdkptp. Needs to be run once each time you start the camera:

Code: Select all

luar call_event_proc("MechaRegisterEventProcedure")
luar call_event_proc("Mecha.Create")
luar call_event_proc("SS.Create")
luar call_event_proc("SS.MFOn")
- Position the focus with this code:

Code: Select all

 luar call_event_proc("MoveFocusLensWithPosition", A, B)
Replace A and B accordingly:

A = Numerical value from 0 to 1840. This is the focus setting; 0 is infinitiy, 1840 is the nearest focus setting.


B = Speed of the focus motor from 1 to 7400, where 1 is slowest and 7400 is fastest.

Values outside these bounds will make the camera crash instantly but dont cause any other apparent harm.
Too low of a speed value will make the camera crash after some time; possibly a timeout.
I found 2500 to 5000 is a good value.


Using this method is the finest possible focus control you can get.
An added bonus is that the minimum focus distance decreases significantly. I assume Canon limited the minimum focus distance to shorten the time the autofocus takes. Its slow as it is.

I then used a bash one-liner - something like this:

Code: Select all

for i in $(seq 1490 1 1510); do chdkptp.exe -c"-d=0001" -e"luar call_event_proc('MoveFocusLensWithPosition', $i, 2500)" -e"rs '$i'_L -tv=1/40 -sv=50 -nd=out" -e"q"; done
with increasingly finer focus steps to find the best focus setting.

Thats how i came across this weird behaviour anyways.


I did some more testing. I dont think it is the alignment. All the lines in a picture are (almost) perfectly parallel.
I could probably mount the camera in a way to maximize the area thats in focus, but then the pages would be skewed.

What i did was take a series of pictures of millimeter paper at different focal points, ran it through imagemagick edge detection and turned it into a gif.

Looks like this:

Image


You can see how the area of sharpness moves across the image diagonally...

I'm guessing that eye-like pattern is due to imperfections in the lenses, the piece of paper is pressed against the platen by a 10kg weight. Its flat.

My second camera shows a similar effect and pattern:

Image

Interesting how there are areas that are never really sharp in the middle of the frame.


Well... I suppose i'll just use focus stacking.

Dont really feel like spending a lot of money on better cameras.

hacki
Posts: 4
Joined: 01 Apr 2018, 19:05
Number of books owned: 0
Country: Germany

Re: IXUS 160 Focal Plane

Post by hacki » 14 Apr 2018, 14:25

So just for closure...


I didnt go with focus stacking afterall. I did multiple exposures for noise reduction instead.
It doesnt really matter if the page is perfectly in focus or not, as long as theres some sort of smooth edge to the letters. They are going to be turned into black and white anyways.

First i dewarped the frames. This does not make a lot of sense, i could have quartered the processing time here if i dewarped the images after averaging. Oh well. :lol:
Unbenannt.gif
Unbenannt.gif (1.01 MiB) Viewed 679 times
I used this tutorial: http://hugin.sourceforge.net/tutorials/ ... n/en.shtml
Instead of taking a picture of a string in my backyard i drew some straight lines on a piece of paper and took a picture of that in the bookscanner at the zoom level i used for scanning the book.

Original frame:
original.jpg
Noise reduced by averaging 4 frames:
denoised.jpg
Unsharp mask and some levels adjustment:
unsharp.jpg
The final image processing step was done with Scan Tailor. Rotation, trimming, converting to black/white mixed mode.
final.jpg
final.jpg (103.27 KiB) Viewed 679 times
All image processing was done with imagemagick in cygwin.

Finally i assembled it into a PDF with Omnipage. The OCR engine is awesome, everything else about that software is a piece of garbage. 32-bit only. No multi-threading. Wonky memory management.
Had to process a 1000 page book in sets of 50 pages because it would act up, hang, crash, or not even allow me to save the project with too many files.


Now i dont know if that noise reduction by image averaging was necessary. It slowed the whole process down considerably.
In my case, that didnt matter, since i am not planning to scan books all too often.

The result i got is very clean, easily readable and with virtually perfect OCR results as well.

Guess i'll do it like that the next time around as well.

dpc
Posts: 286
Joined: 01 Apr 2011, 18:05
Number of books owned: 0
Location: Issaquah, WA

Re: IXUS 160 Focal Plane

Post by dpc » 15 Apr 2018, 23:38

Might be interesting to see the ScanTailor result of that same page without using your image averaging step. What ISO setting are you using?

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests