applying resize from a "calibration" image

New to rawtherapee, and shooting in raw formats in general.

I have a collection of images (photoscan of a book, actually) that I’m trying to edit prior to turning it into an ebook. Everything that I’m doing in rawtherapee is rough edits - compensating for less than ideal lighting, a rough crop (but not fixing perspective, I might do the rotation, or might fix that in the next step), what I do want to do is upscale/fix dpi/ppi so that my images are at least close to real size. I have a “calibration” image - an 8" black square with a 2" mid-gray square in the center. I’m wondering if it is possible to use pixel counts on that image to help with applying an upscale to all the other images? (am I making any sense in explaining what I have and what I want to do?)

Hi @nightshift, welcome to the forum! Digital images don’t have physical sizes. At most, they have metadata that merely suggest what size it should be displayed/printed. To know what needs to be done, we need to know how you are creating the ebook. Specifically, how is it determined how big the images appear? Is it by pixel dimensions only, or by the dpi metadata in the image? Also, how have you scanned the images? Are they all at the same scale (e.g. if the 2 inch square is 200 pixels wide, does 200 pixels represent 2 inches for all the images)?

Thank you for getting back to me.

After I make my corrections in Rawtherapee (and export to probably high quality jpg, but might go for the 8bit tiff, haven’t decided yet), I feed them in to another program that does some additional, guided adjustments, including “fixing” a dpi in metadata (if the metadata dpi doesn’t make sense, which is mostly disgarding outliers of less than 100, more that 9999 or just blank), splitting text from actual pictures, and a few other things and outputs a tiff for each page. That tiff goes through OCR, and then the whole thing gets sent through a pdf binding script/console program (the one I’ll probably use is written in Ruby, just in case all this matters. Image apparent size, and what the file pdf reports as the “page” size will be based on the dpi metadata in addition to pixel dimensions.

Unfortunately, my scanner (a book cradle and tripod combination) does not have a fixed lens to page distance - there are ones that do, but I had to make due with a simpler setup - so, there is some drift, if the first image is 2" x 2" and 200px x 200px, there is a little bit of drift over successive images, such that by the next calibration shot, the square might only be 150px (pulling some numbers out of thin air here, I haven’t actually checked them yet - actually, it looks to be somewhere around 30-40 pixels difference - 600 to start, 572 about 2/3 of the way through, I don’t have a calibration shot for the last page). The second step software can compensate for this, some, but I don’t know how much, yet.

Edit to add - checked the largest probable difference.

Second Edit - pre-cropping pixel dimensions are 4608 x 3456, with a lot of wasted pixels (exactly how many differs from one book to another because of aspect ratios not matching). The camera produced jpg is at 180ppi which, on a different scan that doesn’t have calibration shots with it yields an oversized printed/apparent size (16"x12" instead of the 11 1/8" x 8 3/8" actual size) once cropped according to gimp. Slightly increasing ppi/dpi in the meta will get me closer to actual size, but the second step needs at least 300dpi for text, and supposed to go to 600 for images, but I haven’t done a run to see if it makes a difference.

Sorry for taking so long to respond. I haven’t had much time recently.

Since you are able to determine the number of pixels for a physical dimension, you could calculate the ppi and set it in the metadata. No scaling necessary which would reduce the quality due to resampling. The exception is if the PDF software scales the images and you don’t trust it to do a high-quality resampling.

Where do the 300 dpi and 600 dpi requirements come from? That’s difficult to achieve from photographing the originals. A 11 1/8 x 8 3/8 page at 300 dpi already requires 3338 x 2513 pixels. That gives you some wiggle room, but 600 dpi is impossible without stitching. You also have to contend with softness from imperfect focus and lens aberrations.

Not a problem on the delay, I understand time constraints.

The 300 and 600dpi are coming from the second stage processing (ScanTailor Advanced) which takes the photos (most people shooting just in jpg with compact pocket cameras, but, they have better cradles and frames and most are scanning mostly text pages) converts them to tiff images that with the right pdf software/scripting can create DJvs or PDF files that almost look and function like they were exported from the desktop publishing software - meaning that pictures are placed on the page separate from the text, if you add an ocr step which I do want to, can do a search within the file, and even highlight and copy/paste from it. I may have misunderstood the 600dpi suggestion, there was some conflicting information on that and most of the people that use the software have stopped participating in forums and such (apparently I’m 5 years late to do it yourself document archiving builds, most everyone buys hardware with proprietary software if they are starting now, it seems like). The ocr, apparently, is fairly strict on the 300dpi, but can do ok with a little less if that’s the best one can get without getting too soft for the letter shapes to be recognizable.

I’ll work a little more with the images I have, and maybe some new ones, to see if I am understanding getting pixel dimensions of an area without using external software. If not, I’m sure I’ll be back.

Ok, I played around a little bit, and I’ve figured out how to set ppi to get the printed size close to “actual” size based on something with known physical size within the frame, so, hooray for progress. There are still some potential problems. (Note, my example images came from an early shoot - there are problems with tripod angles, zoom level and a few other things, some of this might be moot for the later shoots where those were improved that I haven’t started processing yet. I resized as needed to meet forum file size limits, so, pulling metadata isn’t really going to tell you anything useful.)

As you can see in the screenshot, I got an almost acceptable 243 ppi while maintaining something close to the “printed” size I want. But, here’s the problem - while I haven’t tried it yet, OCR is pretty specific about wanting 300 ppi/dpi for good recognition. Second step processing might be able to manage the upscale, I haven’t tried that yet either, but, just in case, is there really no setting that lets me say " upscale to x ppi, maintain printed size"? I don’t mind doing the math, would just be easier to not have to.
rawtherapee

That resize option doesn’t exist yet (see Allow resizing to physical dimensions · Issue #4894 · Beep6581/RawTherapee · GitHub). I’m doubtful that resizing will help. Up-scaling the image adds no information for the OCR software to use. At most it will just silence the warning. If the OCR doesn’t work well, the best thing you can try is to increase the quality of the source images (fill the frame, use a low ISO then ETTR, find your lens’s “sweet spot” aperture, etc.). If you want to up-scale, you can stick to simple math by using a scale factor of 2 and doubling the PPI (for example, 486 in your screenshot).

That makes sense. I can reshoot this one, with fewer wasted pixels, just was hoping not to (some of the others, I don’t have a whole lot of wiggle room for filling the frame without cutting off needed information (mostly the black areas for making sure colors are at least somewhat accurate) because of their size. I’m a little limited on aperture and such because I’m using a Canon “bridge” camera, with CHDK giving me a few more DSLR like functions - among them the ability to shoot dng/raw, my camera doesn’t support them natively. There might be an option for specifying a few more settings, but, I would just be throwing random values for that as I really don’t know much about photography (as much as I’d love to know more, I’m just not there).