I Touched Up a Special Photo

Good Morning from my Robotics Lab! This is Shadow_8472 with a 1-night special project based on a mini-project I did a few weeks back. Let’s get started!

I’m no stranger to using my family’s photo trunk as fodder for a long-running project. Besides, there’s a special occasion coming up, and I thought it would be nice to restore a special photo where the photographer had his flash misaligned.

The first part was smuggling one of the scanners up to my room, where it wouldn’t be so obvious that/when I’m working on it. For reference, I’m working with an Epson Perfection V550 Photo and Manjaro Linux. My previous attempts at getting this and another Epson Perfection working with Linux using a driver called SANE were spotty at best. I even went so far as to save a cloned drive over my difficulty in reproducing my success.

> SANE: Scanner Access Now Easy

Long, boring story short: I landed at sane-project.org, where the whole series of Epson Perfection V[100-600] Photo is listed as “unsupported.” [1] The only reason I got it to work before was because I had Image Scan! for Linux installed, as I learned through a combination of user-forsaken forums and personal experimentation. My notes for this project made note to mention “[Epson Perfection V series scanners are] supported by the epkowa backend plus non-free interpreter.” I stopped trying to fully sort its meaning out after getting the V550 working thanks to an AUR package.

> AUR: Arch User Repository

With a working scanner, it wasn’t much more trouble to connect it to the XSANE plugin for GIMP, where I made a collage of different scans with slightly different settings. It took a while to zoom in and align each piece pixel-perfect; ironically, this process was aided by the dust and scratches I couldn’t get off. To finish off the project, I used a feathered eraser tool to smooth the edges.

Takeaway

If I had more time, I’d have feathered the edges after each scan. Like I said, this was a project I am finishing last-minute. I now have the picture looking the best it has in years, but it’s still due for plenty of help – some beyond my skill level.

Final Question

I have a pretty strong feeling I know the answer, but do scanner drivers communicate any additional information when optimizing a scan, or was I just needlessly exposing a special picture to extra light?

Work Cited

SANE, “SANE: Supported Devices,” sane-project.org, [Online]. Available: http://www.sane-project.org/sane-mfgs.html#Z-EPSON. [Accessed Mar. 13, 2023].

Removing Backgrounds With GIMP

Good Morning from my Robotics Lab! This is Shadow_8472, and today I am editing pictures for my church’s photo directory. Let’s get started!

My Background

I first learned the basics of photo manipulation in high school using Photoshop. Pictures can be split apart, remixed with other pictures or original (hand drawn) elements with a wide variety of tools, and sent back out for use elsewhere. The whole operation is organized in a series of layers with their won operations.

Photoshop is not a bad program, but ever since Adobe moved their product to a subscription model, service has have improved for people who use their products consistantly. But for people like me who only need it once every few years and at a moment’s notice, monthly or yearly payments are a terrible investment. I own an old copy of Photoshop, but even then the liscence is a pain to move from computer to computer — and if memory serves, it’I’m limited to the total number of computers it can ever rest on.

GIMP (GNU Image Manipulation Program) is a comparable, free and open source alternative. And in true Linux fashion, it focuses on a small core feature set to serve the vast majority of users’ needs while specialized functionality can be added with extensions. Contrast that with Photoshop loading every tool imaginable for everyone who won’t use but a quarter of them at most. In short: Photoshop has more polish, but GIMP is easier on system resources.

Selecting and Removing a Background

My church produces a photo directory every few years. Families grow, and pictures need updating. I was given a number of pictures and was expected to remove their backgrounds or else turn them white. Photoshop’s tool of choice would have been the quick select tool, but GIMP won’t have a perfect counterpart for this simple tool until GIMP 3.0. Instead, I taught myself the foreground select tool, which I would describe as resistant to learning by trial and error.

The foreground select tool has multiple phases. In GIMP 2.10 specifically, you start with a selection loop, overestimating your subject. You can use line segments or hand drawn boarders, whichever you deem most reasonable at the time. Endpoints are freely adjustable once you’ve closed the loop.

Hitting Enter will put you in phase 2. Here, the whole picture takes on a blue tint (The color is adjustable, but I didn’t learn how). The goal here is to paint in your clear foreground, heavily tinted background, and a lightly tinted buffer between them called “unknown” or “unknown pixels.” Tool options let you switch between what zone you’re painting.

Here, more than anywhere else, it’s particularly picky about keeping on task. I lost about two hours total because I did something just a little too unrelated and the foreground select tool sent me back to phase 1 with no way to undo. It is best to save other tasks in the workflow for later, like adding an alpha (transparency color) channel or duplicating/hiding the original picture layer for quick reference.

Phase 3 will “[calculate] the alpha value of unknown pixels” referring to your boarder zone. It provides a preview of exactly what you’re selecting and lets you make further adjustments, but it will recalculate everything each paintbrush stroke you make. I recommend finding the small dialogue box that lets you disable the preview, effectively reverting to the more economical phase 2. By going back and forth between these two phases, you can tell where the algorithm understands your selection and where it needs more help. Hitting one enter while in phase 3 will finalize your selection.

Training Family

One of the more rewarding parts of this experience was teaching my father this tool, though there were unique challenges. At one point, he was having frustrations getting the tool to cooperate. I had worked with this tool using two or three computers, but his description of what was happening sounded alien to my experiences.

I took a look at his workflow, and GIMP was skipping straight from what I’m calling phase 1 to phase 3, forcing him to use long strokes or face tons of extra recalculation time. Long story short, while I was trying to make his tool icons larger, I found he was on GIMP 2.8, the latest available in the Linux Mint repositories. The GIMP download page directed me to a GIMP 2.10 flatpack installer. The system still prefers GIMP 2.8 when unspecified, but he figured out how to proceed, so that’s a tech support topic for another day.

Color to Black and White

Later on, the software for the directory was making some pictures way too dark. Photoshop has a layer filter for this exact use case with six sliders to adjust different color ranges. GIMP doesn’t include any layer filters, but I was able to make a crude approximation of this tool. Just know there may be a better way to do this and I don’t know it — plugin or otherwise.

To make the perfect black and white version of a color picture, I would start by adding a white background and merging layers if necessary. Next, I menued over to an option to decompose the color channels to a new document. With each layer in grayscale, I added another white background and used Color to Alpha on the red, green, and blue color channel layers. I then adjusted the opacity of each layer until I had a result I was happy with.

Each picture was its own challenge. Most times, I would have one layer carrying most of the data while reducing the other two dramatically. Too little color data, and the picture would fade. Too much, and it would go dark. I targeted a mix where the picture would pop and my eye would relax a little while looking at it.

Takeaway

Both GIMP and Photoshop are wonderful pieces of software in their own rights. I’ve had a class on Photoshop, so of course I’m going to find it easier to navigate that program, even if it’s been years. Despite my slim requirements of advanced photo editing, GIMP’s slim feature set slimmed out a feature or two I miss.

Final Question

Have you taught yourself both Photoshop and GIMP? Which is harder to learn?

Family Photo Chest Part 14: The Tracks are Built, Bring on the Locomotive

Good Morning from my Robotics Lab! This is Shadow_8472, and today I am technically ready to start my first batch of scanning photos. Let’s get started!

Early Start

I am tired of this project going seemingly forever. Whatever I’m getting done, I want working this week. My plan has been to scan directly into the DivideScannedImages script for GIMP, and for that I need the XSANE plugin (Scanner Access Now Easy for Xorg GUI server). Every version I found was ancient and obsolete. Turns out installing the plain XSANE included its own GIMP plugin, as confirmed by xsane -v and looking for a line about GIMP. Just know that if you’re trying to check the version over SSH, that it really wants an Xorg server: export DISPLAY=’:0′ worked for me.

GIMP has a powerful scripting language built in. With it, you can automate most anything, all be it with a little difficulty. You can even use it to script events when launching GIMP with the -b flag (b as in batch). I took a look at it. It doesn’t look that bad to learn. It’s heavy on the parentheses, but I’d hesitate to directly call it LISP.

I got as far as calling the XSANE plugin on boot from within the DivideScannedImmages script. I was a little short on time to struggle through getting it just right, so I reached out for help on a GIMP Discord, but then I began to reconsider everything.

Progress Rejected

I’ve been a bad programmer. So many dead ends. So many side projects distracting from the main goal. I have an unknown deadline for this project, and I really need to cut the fancy stuff I’ve been working on and do something that actually works.

I also got to thinking, Who am I designing this for? I had been working on a command line setup for me, and my mother has graciously offered to help with scanning a little bit at a time. She doesn’t do the command line outside Minecraft. As a good programmer, I need to consider my end user’s needs, and she needs a graphical workspace.

Thinking like my mother would think, I made a directory on my desktop for shortcuts related to this project. So far, I’ve made launchers for XSANE, the network share for the pictures, and GIMP. I may develop it later.

My new vision is to just use the tools I have: XSANE to scan and save locally and GIMP to separate and deskew pictures automatically and store them in the digital archive before someone either deletes or offloads the original scans. I can make a text file with miscellaneous metadata for each batch. A manual review can flag photos that will need additional touchup.

Testing the Workflow

I used a couple pictures from when I was little to test my workflow. I laid them on the scanner with a bit of tweak. I spent several attempts learning about the limits of the scanner. The scan head doesn’t actually reach the full scan bed. If I’m not careful, pictures will get pinched under the edges. It’s very easy to accidentally overlap pictures. All good reasons for finding a preview of each scan.

Deskew isn’t a miracle, but when I did a side-by side comparison on a sample size of my two test pictures, it got one almost perfect and reduced the the tweak from the other, but my sister said the deskewed one might be a little fuzzier.

Takeaway

I cannot emphasize this point enough: good programmers build software for end users. It’s fine to hack together a piece of software you understand, but if you want to share your creation with someone else, you’ve got to make a relatable front end.

Final Question

What elements of a project have you given up for the sake of an end-user?

Family Photo Chest Part 12: Early Prototype Workflow

Good Morning from my Robotics Lab! This is Shadow_8472, and today, I’m recounting the tale of my first working prototype, and how I ruined it before getting it to actually work. Let’s get started!

Pi4 8GB and Cards

I am now the owner of a Pi4 with 8GB of memory, the highest end Pi available at the present time. When I unboxed it, I put it directly into a case with a fan powered by GPIO pins. Some day, I’ll want to benchmark its cooling against my Pi 4 with the huge heatsink case and passive airflow.

The cards I had on order never came in, and their listing vanished in the meantime. I ended up with some 64GB cards from Gigastone that are supposed to be better on paper, but I’m not in a position to benchmark the Raspberry Pi use case. While these new cards only have one SD adapter between them –I’ve been using SD adapters for labels– they did include a USB adapter. It’s only 2.0, though.

Manjaro ARM

I have not fully settled on what distro to go with for this project. TinyCore is great for starting projects, but I have a hard time finishing it there. For the time being, I’ll be prototyping from my Manjaro ARM card. Whenever I need to reset, I can boot a Pi to Raspberry OS and arrange for a direct dd from my master Manjaro card to the newer, larger card.

Side note: While performing my first wipe, I noticed dd did NOT automatically expand the partition like I thought it did. Once I have things working better, that may be a possible improvement to look at for a new master Manjaro card.

Prototype GIMP Configuration

First order of business was installing GIMP and XSANE plugin for GIMP. They worked first try, but XSANE only recognized a shared network printer all in one with a scanner built in, ignoring the local USB scanner I cannot seem to arrange access permissions for correctly. I think I spent half my time this week on this problem exploring dead ends.

The most important missing piece to the puzzle has been a script called Divide Scanned Images. With it, I can feed it scans containing multiple pictures, and it can separate and crop them automatically with the option to deskew (rotate to vertical) if an appropriate utility is found. Link to blog about script: how-to-batch-separate-crop-multiple-scanned-photos. Linked on that page in a comment by user Jan is a Linux-compatible version of Deskew (I have yet to get it to work).

Eager to test what I did have working, I went ahead with using the scanner on the network. I had someone put some picture stand-ins on; I got two seed packs. To my annoyance, the separation script appears to only work with pictures on file and not freshly scanned in, making it a completely separate process. As mentioned above, Deskew refused to work. I suspect I either didn’t put it in the right place or I was working with a copy compiled for an x86 processor while on an ARM based system, though it could be as simple as shadows from the seed packs.

Struggling With the Scanner

I find SANE to be an ironic acronym: Scanner Access Now Easy. I still don’t have Linux scanners figured out. I know there’s an easy way with security implications I’ve stumbled my way through before. I also have learned that differences between distros make the Ubuntu page I keep getting thrown to for help useless in parts. Whenever I post for help on Discord, someone else comes along with another question and mine gets buried.

Along my journeys, I’ve learned about a scanner group. I tried adding it to my profile, and somehow managed to get what appears to be a fake group. After a long time trying to figure out how to safely remove it so I could add the real one, I managed to remove myself from all my default groups including my ability to use sudo, and I don’t believe a root account is set up on this card. It even said the incident would be reported. Any such black mark never had a chance to be transmitted over the Internet –WiFi was down for USB scanner diagnostics– before I dd‘ed the master copy back over it.

Another attempt had me searching through the local files for answers. sane-find-scanner and anything looking at the USB port directly can see the scanner right away, but scanimage -L to list devices SANE sees comes up with nothing when off the network. I can’t reproduce my exact path on the laptop I’m working from, but I found a tip to check /etc/sane.d/ for appropriate config files. If I understand epson.conf there correctly, my problem is either elsewhere, or I need both a product ID and a device ID, the later of which I still have no idea how to locate.

Revised Workflow Proposition

In the light of GIMP seemingly not wanting to split pictures live in memory, it may be a good idea to offload that task to a more powerful computer that can handle two Pi’s operating scanners and saving to a network share hosted on an SSD before saving the pictures to GoldenOakLibry. Touch up can then happen in-place.

Takeaway

While I’m glad to have gotten a subpar prototype operational, it’s only about 60% of the process demonstrated at once. Still, it was the missing pieces demonstrated, and the toughest spot was exactly where I expected from past experience. This is already Part 12 of this ongoing series, and I want to finish before another 12 parts go by. Any month may be the month, and no matter how down I feel at the end of work on it, I still made a major goal this week.

Final Question

What was the biggest mistake you’ve ever made but still had a minimal effort fix for?