Channel separating script Mac and Linux

General discussion about StarTools.
Post Reply
Rowland
Posts: 235
Joined: Sat Mar 05, 2011 10:54 pm

Channel separating script Mac and Linux

Post by Rowland »

Here is a very simple command line script for separating an RGB image into R G B L and L* (lightness in LAB) channels = approx 10 seconds on my 8GB system

Requires ImageMagick

Works in Linux and should/will work in MacOS. I'll investigate a windows version.

Update: new version a few posts down

1. Copy the channels file to the same directory as the RGB file to be processed
2. Open a terminal in the same directory
3. Type - followed by Enter

Code: Select all

./channels
script asks for file name and bit depth - 16 maximum. Creates lrgb directory and writes R G B L and L* frames to it.

If bash complains with Permission denied, do;

Code: Select all

chmod +x channels
Same input and output format
channels.zip
(905 Bytes) Downloaded 499 times
Last edited by Rowland on Sat Nov 11, 2017 1:16 am, edited 1 time in total.
Guy
Posts: 158
Joined: Thu Feb 19, 2015 8:35 am

Re: Channel separating script Mac and Linux

Post by Guy »

That's a quick and neat approach.

An alternative, manual, way to do this is using StarTools' LRGB module.

Load the colour image in the LRGB module using the Luminance button, keep the result, and save it as the Luminance file. Repeat using the Red, Green and Blue buttons, creating a separate file each time. Channel Interpolation should be on so you will end up with a black and white representation of the selected channel. See the Description of Controls section in the LRGB Module Use notes.
You can get the CIE L*a*b 'L' component data file by loading the colour image - then, in the Color Module, set Saturation to 0%, keep and save the image. See the description in IC342 - second image in StarTools.
Rowland
Posts: 235
Joined: Sat Mar 05, 2011 10:54 pm

Re: Channel separating script Mac and Linux

Post by Rowland »

Guy. I have been reading your excellent and comprehensive user notes. They are worth their weight in gold. Thank you.
-----------------------------------------------

Here is an improved version of the script for use with most image formats. However, I am investigating why imagemagick is not reading the colour information in the .fts multi-layered files produced by DSS...?

EDIT: FITS analysis indicates a variable expansion error... whatever that is and the file does not conform to fits. IM could not find a color profile, however, it must have a profile of sorts. Suggest save DSS files as tiff for use with this script, until I can get to the bottom it.

Basically, the script separates all the channels R G B L. But with some formats, L splits into several layers which need to be average or mean combined to create the L channel. Interestingly, the L in Lab does the same thing.
channels.zip
(996 Bytes) Downloaded 509 times
Guy
Posts: 158
Joined: Thu Feb 19, 2015 8:35 am

Re: Channel separating script Mac and Linux

Post by Guy »

Hi Rowland,

Thanks. I had a lot of help compiling them from Ivo and others, and the forums have a lot of interesting ideas. I'm always interested in new ways to get better results - so if you have any favourites please let me know.

Definitely off-topic - I noticed you used ImageMagick for some analysis - does it provide good tools for image analysis? I'm looking for a package that is freely available that does good basic image analysis to help in identifying image problems.

Regards
Guy
Post Reply