Extract RGBI image from multipage TIFF
Re: Extract RGBI image from multipage TIFF
There's not another tool I've successfully used for this. I'll either keep the slides as-is or rescan them. Thanks for the valiant effort!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Extract RGBI image from multipage TIFF
Here is one other attempt. I get the alpha channel from layer 2 and apply it to layer 1.
http://www.fmwconcepts.com/misc_tests/example_im_2.tif
Does that work?
Code: Select all
convert example.tif[0] \( example.tif[1] -alpha extract \) \
-alpha off -compose copy_opacity -composite \
-define tiff:rows-per-strip=1 -define tiff:alpha=unspecified example_im_2.tif
Does that work?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Extract RGBI image from multipage TIFF
I have a feeling that your original tiff looks different from the extracted tiff, because Photoshop is merging the hidden layer with the visible layer and so it looks darker than either layer.
Out of curiosity, how did you manage to scan (or create) the image and get two layers in the tiff? Can you not recreate it in such a way that you only get one layer?
Out of curiosity, how did you manage to scan (or create) the image and get two layers in the tiff? Can you not recreate it in such a way that you only get one layer?
Re: Extract RGBI image from multipage TIFF
Thanks for trying again. My problem has nothing to do with layer 1 of the tiff though, so we can totally ignore and discard layer 1.
Here's exactly what I'm trying to do:
1. Extract only layer 2 from the two-layer tiff into a new tiff.
2. Take the new tiff and "fix" the alpha channel so my third-party software, VueScan, will recognize it as "infrared." I realize this might not be possible, though.
If this works, I'll apply the method to hundreds of such two-layer tiffs I've already made, in order to make them compatible with VueScan.
Here's the brief history of how I made the two-layer tiffs:
I'm an archivist and I'm in the process of scanning and storing thousands of slides. I have a special slide scanner which, in addition to scanning slides for RGB colors like a typical scanner, also scans for dust with an infrared light. This works because infrared light will not penetrate through dust; therefore you end up with a "digital dust overlay" for a slide which you can then use to automatically erase dust in VueScan.
You also have the option to save your scanned image as either a 48-bit RGB image or a 64-bit RGBI image. The 64-bit RBGI option is RGB + the infrared channel (probably very similar to an alpha channel), and I'm pretty sure this format was designed only for VueScan. You can then open the 64-bit RGBI image again in VueScan at a later date and automatically clean up the dust, because it still contains the special infrared channel.
At the beginning of the project I decided I wanted to have two versions of every scan. The first version would be the original scanned image without dust removal, in case I ever wanted to manually remove the dust in the future. The second version would be dust-free thanks to VueScan's cleaning feature. Since there would be two versions of each image, I decided to combine them into a single two-layer tiff file for tidiness. That's where ImageMagick came in. I didn't realize that ImageMagick wouldn't know how to deal with the VueScan-specific infrared channels.
So here's what I did step-by-step:
1. Scan a slide into VueScan.
2. Without cleaning up the dust, save the scanned image as original.tif, 64-bit RGBI.
3. Clean up the dust in VueScan and save again as cleaned.tif, 48-bit RGB (no infrared/alpha channel, just normal RGB).
4. Use ImageMagick to combine them into one tiff like this: convert.exe cleaned.tif[0] original.tif[0] full.tif
5. Once they are combined, delete the two original files.
After scanning and processing many, many slides this way, I then realized that when I extracted any "Layer 2" (original scanned image) from these tiffs and opened it in VueScan to work with the original dusty image, I couldn't do the auto-dust removal. The special infrared channel probably had been damaged or converted to a normal alpha channel by ImageMagick.
Now I'm in the situation where I have hundreds of these two-layer files, and I need to either repair all the "layer twos" (the layer that is the original, dusty slide with the infrared channel) or rescan all these slides.
I hope that makes sense! Thanks again.
Here's exactly what I'm trying to do:
1. Extract only layer 2 from the two-layer tiff into a new tiff.
2. Take the new tiff and "fix" the alpha channel so my third-party software, VueScan, will recognize it as "infrared." I realize this might not be possible, though.
If this works, I'll apply the method to hundreds of such two-layer tiffs I've already made, in order to make them compatible with VueScan.
Here's the brief history of how I made the two-layer tiffs:
I'm an archivist and I'm in the process of scanning and storing thousands of slides. I have a special slide scanner which, in addition to scanning slides for RGB colors like a typical scanner, also scans for dust with an infrared light. This works because infrared light will not penetrate through dust; therefore you end up with a "digital dust overlay" for a slide which you can then use to automatically erase dust in VueScan.
You also have the option to save your scanned image as either a 48-bit RGB image or a 64-bit RGBI image. The 64-bit RBGI option is RGB + the infrared channel (probably very similar to an alpha channel), and I'm pretty sure this format was designed only for VueScan. You can then open the 64-bit RGBI image again in VueScan at a later date and automatically clean up the dust, because it still contains the special infrared channel.
At the beginning of the project I decided I wanted to have two versions of every scan. The first version would be the original scanned image without dust removal, in case I ever wanted to manually remove the dust in the future. The second version would be dust-free thanks to VueScan's cleaning feature. Since there would be two versions of each image, I decided to combine them into a single two-layer tiff file for tidiness. That's where ImageMagick came in. I didn't realize that ImageMagick wouldn't know how to deal with the VueScan-specific infrared channels.
So here's what I did step-by-step:
1. Scan a slide into VueScan.
2. Without cleaning up the dust, save the scanned image as original.tif, 64-bit RGBI.
3. Clean up the dust in VueScan and save again as cleaned.tif, 48-bit RGB (no infrared/alpha channel, just normal RGB).
4. Use ImageMagick to combine them into one tiff like this: convert.exe cleaned.tif[0] original.tif[0] full.tif
5. Once they are combined, delete the two original files.
After scanning and processing many, many slides this way, I then realized that when I extracted any "Layer 2" (original scanned image) from these tiffs and opened it in VueScan to work with the original dusty image, I couldn't do the auto-dust removal. The special infrared channel probably had been damaged or converted to a normal alpha channel by ImageMagick.
Now I'm in the situation where I have hundreds of these two-layer files, and I need to either repair all the "layer twos" (the layer that is the original, dusty slide with the infrared channel) or rescan all these slides.
I hope that makes sense! Thanks again.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Extract RGBI image from multipage TIFF
Yes, thanks for the explanation. But did my last command not work to allow you to open the output file (containing only layer2) and process it in VueScan. I can open the output file in PS and see your RGB and I where I is an alpha channel (mask). If not, then can you send your original.tif so I can open it in PS and see how it is different from the layer 2 of your IM created tif.
Re: Extract RGBI image from multipage TIFF
Well, your example is outputting the first layer with the alpha from the second layer, right? I don't need the first "page" in the tiff, only the second. Sorry if I'm missing something.
At any rate, your file (http://www.fmwconcepts.com/misc_tests/example_im_2.tif) doesn't work in VueScan. It's a little too transparent, just like the last few ones. Thanks.
P.S.: Here are two example files again, both the same image. You might already have these.
64-bit RGBI image directly from VueScan: https://drive.google.com/file/d/0B9eUF3 ... sp=sharing
64-bit RGBI extracted from a two-page tiff: https://drive.google.com/file/d/0B9eUF3 ... sp=sharing
At any rate, your file (http://www.fmwconcepts.com/misc_tests/example_im_2.tif) doesn't work in VueScan. It's a little too transparent, just like the last few ones. Thanks.
P.S.: Here are two example files again, both the same image. You might already have these.
64-bit RGBI image directly from VueScan: https://drive.google.com/file/d/0B9eUF3 ... sp=sharing
64-bit RGBI extracted from a two-page tiff: https://drive.google.com/file/d/0B9eUF3 ... sp=sharing
Re: Extract RGBI image from multipage TIFF
If you happen to be interested, you can download the trial of VueScan and see for yourself exactly what I'm talking about, and you can try the dust cleaning yourself and see if it works. It's about 10 MB. https://www.hamrick.com/download.html
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Extract RGBI image from multipage TIFF
Here is an interesting test for you. Do you have Photoshop? If you do, just open your one layer RGBI TIF in PS and save to a new TIF. Can you process that file in VueScan. When I do that and look at the Poperties, there are differences. In particular, the tiff:software: VueScan 9 x64 (9.5.67) has been changed to tiff:software: Adobe Photoshop CS Macintosh for the PS result and there is no tiff:software in the IM result. So if Vuescan cannot process the new files, it might be due to a loss of the tiff:software VueScan 9 x64 (9.5.67) to indentify the alpha channel as your I channel for VueScan
Your original:
The output from PS:
The output from IM:
Here is my PS extracted TIF:
http://www.fmwconcepts.com/misc_tests/r ... can_ps.tif
Here is my IM extracted TIF:
http://www.fmwconcepts.com/misc_tests/r ... can_im.tif
Do either of these 2 files open and clean in VueScan?
All 3 files look identical in PS.
If they work, then there is something about how IM has combined your two layers in a TIFF file or how IM is trying to extract the second layer, since it is hidden. So send me your cleaned RGB tiff file and I will try combining it with the RGBI file above and see what happens when I try to extract the second layer.
Your original:
Code: Select all
Properties:
date:create: 2017-02-07T18:18:04-08:00
date:modify: 2017-02-07T18:18:04-08:00
exif:DateTimeDigitized: 2017:01:30 17:28:10
label: Transparency
signature: ebc470192f571902b90020eb9bfd2a21d4ca7226fa602b06accf8fe2ca3638e0
tiff:alpha: unspecified
tiff:endian: lsb
tiff:make: Nikon
tiff:model: LS-5000
tiff:photometric: RGB
tiff:rows-per-strip: 1
tiff:software: VueScan 9 x64 (9.5.67)
Artifacts:
filename: raw-from-vuescan1.tif
verbose: true
Code: Select all
Properties:
date:create: 2017-02-07T18:20:49-08:00
date:modify: 2017-02-07T18:20:49-08:00
dc:format: image/tiff
exif:DateTimeDigitized: 2017:01:30 17:28:10
exif:PixelXDimension: 5780
exif:PixelYDimension: 3944
signature: 09fb22cb94a29c7940a26c9fab6471d1f737d69a4ac9211b659f7c724640f0b4
tiff:alpha: unspecified
tiff:endian: lsb
tiff:Make: Nikon
tiff:Model: LS-5000
tiff:photometric: RGB
tiff:ResolutionUnit: 2
tiff:rows-per-strip: 1
tiff:software: Adobe Photoshop CS Macintosh
tiff:timestamp: 2017:02:07 18:20:38
tiff:XResolution: 1048576000/262144
tiff:YResolution: 1048576000/262144
xap:CreateDate: 2017-02-07T18:20:38-08:00
xap:CreatorTool: Adobe Photoshop CS Macintosh
xap:MetadataDate: 2017-02-07T18:20:38-08:00
xap:ModifyDate: 2017-02-07T18:20:38-08:00
xapMM:DocumentID: adobe:docid:photoshop:88bcf775-eef3-11e6-bb79-d5053007d87e
xmp:DateTimeDigitized: 2017-01-30T17:28:10-08:00
Profiles:
Profile-8bim: 11302 bytes
Profile-xmp: 6096 bytes
Artifacts:
filename: raw-from-vuescan3.tif
verbose: true
Code: Select all
Properties:
date:create: 2017-02-07T18:48:40-08:00
date:modify: 2017-02-07T18:48:40-08:00
label: Transparency
signature: ebc470192f571902b90020eb9bfd2a21d4ca7226fa602b06accf8fe2ca3638e0
tiff:alpha: unspecified
tiff:endian: lsb
tiff:photometric: RGB
tiff:rows-per-strip: 1
Artifacts:
filename: raw-from-vuescan_im.tif
verbose: true
http://www.fmwconcepts.com/misc_tests/r ... can_ps.tif
Here is my IM extracted TIF:
http://www.fmwconcepts.com/misc_tests/r ... can_im.tif
Do either of these 2 files open and clean in VueScan?
All 3 files look identical in PS.
If they work, then there is something about how IM has combined your two layers in a TIFF file or how IM is trying to extract the second layer, since it is hidden. So send me your cleaned RGB tiff file and I will try combining it with the RGBI file above and see what happens when I try to extract the second layer.
Re: Extract RGBI image from multipage TIFF
I do have Photoshop, and I tried what you suggested. I opened raw-from-vuescan.tif, saved it as another tiff, and opened that in VueScan. No problems there. The infrared clean works just fine on the new file.
A few days ago I already tried adding/removing the "VueScan 9 x64 (9.5.67)" and it didn't have any effect that I could notice.
Both of your tiffs (raw-from-vuescan_ps.tif and raw-from-vuescan_im.tif) do work without any issue in VueScan. Infrared clean is fine.
Here is a cleaned version of raw-from-vuescan.tif:
https://drive.google.com/file/d/0B9eUF3 ... sp=sharing
A few days ago I already tried adding/removing the "VueScan 9 x64 (9.5.67)" and it didn't have any effect that I could notice.
Both of your tiffs (raw-from-vuescan_ps.tif and raw-from-vuescan_im.tif) do work without any issue in VueScan. Infrared clean is fine.
Here is a cleaned version of raw-from-vuescan.tif:
https://drive.google.com/file/d/0B9eUF3 ... sp=sharing
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Extract RGBI image from multipage TIFF
OK. I took your two images, cleaned (RGB) and not cleaned (RGBI) and combined them as a two layer tif. Then I extracted the second layer and compared that with your RGBI and get a perfect match.
0 (0)
You can download my two images from the following and see if my extracted RGBI image works in your VueScan. I use IM 6.9.7.7 Q16 Mac OSX to do the processing.
http://www.fmwconcepts.com/misc_tests/r ... mbined.tif
http://www.fmwconcepts.com/misc_tests/r ... racted.tif
If my extracted image works, then send me your combined image and I will try to see what difference there are.
Code: Select all
convert raw-from-vuescan-cleaned.tif[0] raw-from-vuescan.tif[0] raw-from-vuescan_fred_combined.tif
convert raw-from-vuescan_fred_combined.tif[1] -define tif:alpha=unspecified raw-from-vuescan_fred_combined_L1_extracted.tif
compare -metric rmse raw-from-vuescan.tif raw-from-vuescan_fred_combined_L1_extracted.tif null:
You can download my two images from the following and see if my extracted RGBI image works in your VueScan. I use IM 6.9.7.7 Q16 Mac OSX to do the processing.
http://www.fmwconcepts.com/misc_tests/r ... mbined.tif
http://www.fmwconcepts.com/misc_tests/r ... racted.tif
If my extracted image works, then send me your combined image and I will try to see what difference there are.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Extract RGBI image from multipage TIFF
What was your exact command to extract the RGBI image from your 2 layer combined tif?
Re: Extract RGBI image from multipage TIFF
Your extracted image works in VueScan (raw-from-vuescan_fred_combined_L1_extracted.tif).
And when I use the same extraction command on your raw-from-vuescan_fred_combined.tif file, the output file also works in VueScan.
But when I try your extraction command on one of my already-combined tiffs, the output file does not work properly in VueScan.
Here's the already-combined image. You might already have this file: https://drive.google.com/file/d/0B9eUF3 ... sp=sharing Again, all my archived slide tiffs are already in this exact format.
I'll repost the screenshot showing the apparent transparency difference in Windows Photo Viewer: http://imgur.com/a/OZYeJ It's an old screenshot but shows the problem.
So in Windows Photo Viewer, when I look at the second layer of your combined tiff, it looks right. When I look at the second layer of my combined tiff, it looks too bright.
I didn't think of this until now, but I'll show you the combine_tifs.bat file I've used to combine the photos:
I'm starting to think that my exiftool.exe commands messed up the output file. This might just be the answer. I'm not even 100% sure why I had those commands, except I know I wanted to fix the "ColorSpace" option, because I thought it was incorrect. I'll let you know any further findings I have. Thanks again!
And when I use the same extraction command on your raw-from-vuescan_fred_combined.tif file, the output file also works in VueScan.
But when I try your extraction command on one of my already-combined tiffs, the output file does not work properly in VueScan.
Here's the already-combined image. You might already have this file: https://drive.google.com/file/d/0B9eUF3 ... sp=sharing Again, all my archived slide tiffs are already in this exact format.
I'll repost the screenshot showing the apparent transparency difference in Windows Photo Viewer: http://imgur.com/a/OZYeJ It's an old screenshot but shows the problem.
So in Windows Photo Viewer, when I look at the second layer of your combined tiff, it looks right. When I look at the second layer of my combined tiff, it looks too bright.
I didn't think of this until now, but I'll show you the combine_tifs.bat file I've used to combine the photos:
Code: Select all
cd C:\Program Files\ImageMagick-6.9.3-Q16
convert.exe C:\Users\User\Pictures\a.tif[0] C:\Users\User\Pictures\b.tif[0] C:\Users\User\Pictures\new.tif
exiftool.exe -delete_original -tagsfromfile C:\Users\User\Pictures\a.tif C:\Users\User\Pictures\new.tif
exiftool.exe -ColorSpace="" -DigitalIce="" C:\Users\User\Pictures\new.tif
del C:\Users\User\Pictures\a.tif
del C:\Users\User\Pictures\b.tif
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Extract RGBI image from multipage TIFF
That sounds dodgy, and might have caused the problem. "Too light" or "too dark" is often a colorspace problem.koyglreg wrote:... except I know I wanted to fix the "ColorSpace" option, because I thought it was incorrect.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Extract RGBI image from multipage TIFF
If you removed the colorspace value, that could be the cause of it. Try using Exiftool to put the original colorspace value back into your files and the same for any other EXIF values you changed or removed. Then try the IM command to retrieve the second layer.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Extract RGBI image from multipage TIFF
Doing a compare on your exiftool modified multipage-with-imagemagick.tif with my unmodified raw-from-vuescan_fred_combined.tif shows quite a bit of difference. So whatever you did to modify it seems to have really changed the image in some way.
Can you create a new multipage image without using exiftool to modify it and then extract the second layer and use it successfully in VueScan?
If so, then can you use exiftool to put back into your existing multipage-with-imagemagick.tif and then successfully extract the second layer and use it successfully in Vuescan?
If that is the case, then exiftool made some bad changes. If not, then it could have been the version IM you were using to create the multipage tiff.
Code: Select all
compare -metric rmse raw-from-vuescan_fred_combined.tif multipage-with-imagemagick.tif null:
21029 (0.320882)
If so, then can you use exiftool to put back into your existing multipage-with-imagemagick.tif and then successfully extract the second layer and use it successfully in Vuescan?
If that is the case, then exiftool made some bad changes. If not, then it could have been the version IM you were using to create the multipage tiff.