Historically, many of us (myself included) have advocated for software features like deskew, despeckle and auto-crop to be done in the front-end. This has obvious advantages for code reuse and maintainability, since there appear to be fewer front-ends than backends. But, I think the biggest reason is more selfish. These features are hard to write, and I, for one, would rather that it was someone else's problem :)
However, many current brands of scanner can do various image processing steps in hardware, but only on the medium & high cost machines. Users of the low cost machines get these features via software in the vendor's proprietary drivers, and don't see any difference. Also, the number of front-ends is a bit of a red herring, since the most popular ones by far are scanimage, scanadf, and Xsane, none of which has yet provided these features. Besides, the first two of these are produced by us, so much for passing the workload to someone else :) So, in the interest of consistency for all users, I have undertaken to provide these features somewhere in sane. I considered adding this type of code to scanimage, but then the users of Xsane cannot reach it. Then I started writing a 'middle-end', but after I got done replicating much of the logic in the dll backend in order to load lower layers backends, I switched to adding the code to the backends directly. Such code has been in the canon_dr backend for a few weeks. Though simplistic, it is fairly well tested, and does work reasonably. Now, to improve reusability, I have spun a more generic version of that code into sanei_magic, updated sane-fujitsu to use it, and committed both to git. Details: 1. Deskew, autocrop and despeckle 2. Deskew and autocrop are each divided into two functions, one to find the appropriate boundaries/angles, and one to correct the image based on those parameters. This gives the caller a chance to inspect and/or change the outcome of the operation. 3. Despeckle takes a maximum diameter to remove, and fills the area with average surrounding color 4. Deskew uses a simplified iterative 'original' Hough transform which searches for the top and left edges of the media inside the image. This is less sensitive to false positives than looking at content, but does not function well if no media edge is visible. I continue to search for alternative mechanisms. With all this code I am certainly open to modifications and adjustments (even renaming, sanei_magic was the best I could do). I will even accept criticism for even including it in the first place, though I think once users take notice of it, these will become popular features. allan -- "The truth is an offense, but not a sin"