ISS Imaging in HDR using SharpCap

Using SharpCap for other Astro Imaging such as all sky cameras and meteor detection
Post Reply
User avatar
admin
Site Admin
Posts: 15380
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

ISS Imaging in HDR using SharpCap

#1

Post by admin »

Some of you may have seen the fabulous HDR images of the ISS captured by Charline Giroud - for example
HDR_pipp.gif
HDR_pipp.gif (1.04 MiB) Viewed 5611 times
(Full Details : https://spacestationguys.com/spom/#2025january)

You can see a bit more about the process here : https://www.facebook.com/reel/1825851937956314

Charline and I worked together on how to capture HDR data of the ISS and how to process that data - she did all the hard work of coming up with the initial idea and actually being in the right place at the right time to image the ISS. All I had to do was the easy part of making a few tweaks so that SharpCap could be used as part of the project.

I'm not going to try covering how to actually image the ISS in the first place - just how to modify the normal imaging procedure to allow for an HDR capture and then how to process the resulting data to extract the bright and dim portions of the capture into separate files.

The HDR Script

The first stage is to use the SharpCap Python script below during capture. The script will change the camera exposure regularly (by default every 0.2s) between a dim and bright setting - this means that the capture will contain portions at the bright and dim camera settings that will need to be separated out later. If, for instance, you are imaging at about 100fps, you will have about 20 bright frames, followed by 20 dim frames, repeating for the duration of the capture.
hdr.py
(1.1 KiB) Downloaded 156 times
To use this file, do the following:
  • Save it to your PC somewhere
  • Make sure you have a recent copy of SharpCap and a SharpCap Pro license (SharpCap Pro is required to use the built in Python scripting system)
  • In SharpCap, go to the 'Scripting' menu, then 'Run Script', then browse for the .py file and let SharpCap run it
Once you have run the script file, you will see two new buttons appear at the right of the SharpCap toolbar - 'HDR' and 'Stop'
Screenshot 2025-05-02 152542.jpg
Screenshot 2025-05-02 152542.jpg (7.82 KiB) Viewed 5615 times
Using the Script

Pressing the 'HDR' button will activate the HDR mode switching between dim and bright versions of the same image. Pressing 'Stop' will stop the HDR exposure changing effect.

You need to have the camera open and the camera settings set up before using the 'HDR' button. In fact, you should set up the gain/exposure of the camera to properly expose the brightest parts of the image - that's because the HDR function will alternate between the exposure you set and one that is 5 times longer (and therefore a 5x brighter image), so your initial settings need to properly expose the highlights - the brighter parts will get the detail in the shadows.

Once you have the HDR function running and the camera switching between bright and dark regularly, just use the 'Start Capture' or 'Quick Capture' function in SharpCap as usual to capture to SER file and capture your video.

I will cover processing the HDR video into separate chunks of bright and dim frames in the next post - on the capturing side there are a last few things to mention...

Customizing HDR Capture

* You can edit the 'ratio' and 'delay' values in the python script to change how much brighter the script makes the bright sections of the video (default 5 times) and how long between exposure changes (default 0.2s). Best to close and re-open SharpCap, then re-run the script after this sort of change

* You can set up SharpCap to automatically load the HDR script at startup - see https://docs.sharpcap.co.uk/4.1/#Start-up%20Scripts for details on how to add/remove and manage 'start up scripts' that run when SharpCap starts.

cheers,

Robin
User avatar
admin
Site Admin
Posts: 15380
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: ISS Imaging in HDR using SharpCap

#2

Post by admin »

If you have successfully captured something using the HDR python script above, you will have an SER file that contains bright and dark sections when you play it back, and processing the file will require those sections to be separated out. There are two tools I have created available to help with this in slightly different ways. Both of them will need to be run from the Windows command prompt as they don't currently have any graphical user interface to control them. Apologies for the fact that these tools are basic and require 'geekery' to use - they are experimental, written to try to get things done quickly while the techniques for HDR are being developed.

Option 1 - SerSplit 1.0

This tool will take the HDR input SER file and split it into two separate SER files - one containing all the darker frames (low exposure) and one containing all the brighter frames (longer exposure). It needs to be run twice, once to anayze the frame brightnesses in the HDR SER file, and a second time to actually do the splitting. Analyzing the frame brightnesses lets you choose a cut off point to distinguish between the darker and brighter frames, which is needed for the second run.

Use it as follows:
  • Download SERSplit.zip from https://downloads.sharpcap.co.uk/tools/SerSplit.zip
  • Unzip SERSplit.zip to get the executable file - SERSplit.exe inside
  • Open a windows command prompt and enter a command like the one below

    Code: Select all

    C:\Users\robin\Downloads\SerSplit\SerSplit.exe "C:\Users\robin\Desktop\SharpCap Captures\2025-05-02\Capture\Light\14_53_15Z_.ser"
    
    The first part specifies where the SerSplit.exe file can be found and the second specifies the SER file to process. The easiest way to get those full files and paths into the windows command prompt is to drag first the .exe file into the command prompt box, then add a space, then drag in the .SER file. Dragging files into a command prompt inserts the full path to the file, which is just what we want here...
  • Run the command like the one above to analyze the SER file - the output produced will be a bit like this

    Code: Select all

    Reading C:\Users\robin\Desktop\SharpCap Captures\2025-05-02\Capture\Light\14_53_15Z_.ser (1000 frames)
    Brightness Stats: (Each line is brightness bin level, count)
    46.58, 512
    54.45, 0
    62.33, 0
    70.21, 0
    78.08, 0
    85.96, 0
    93.84, 0
    101.71, 0
    109.59, 0
    117.46, 0
    125.34, 0
    133.22, 0
    141.09, 0
    148.97, 0
    156.85, 0
    164.72, 0
    172.60, 0
    180.48, 0
    188.35, 0
    196.23, 488
    
  • Read through the output - the important bits are the numbers, which can be read on each line as a 'frame brightness level' (before the comma) and 'number of frames at/near that brightness' (after the comma). It will be usual, like here, for there to be almost all zeros except for the first and last lines of numbers - a few non zeros in between is not an issue.
  • Pick a value from the left hand side of a line that's in the middle - this will be your threshold value - any frames brighter than that will be classed as 'bright', any frames darker than your threshold will be 'dark'. A rough value is fine - here I might choose 125 or 130 or so - the exact value in that range will make no difference as all the frames are either bright (brightness near 196) or dim (brightness near 46).
  • Run a new command - exactly the same as the previous one, but with the threshold value added at the end (note the space!)

    Code: Select all

    C:\Users\robin\Downloads\SerSplit\SerSplit.exe "C:\Users\robin\Desktop\SharpCap Captures\2025-05-02\Capture\Light\14_53_15Z_.ser" 125
    
  • This command will actually perform the split, creating two output SER files in the same folder as the input file - it will create output in the command prompt reporting on what it does a bit like this

    Code: Select all

    Reading C:\Users\robin\Desktop\SharpCap Captures\2025-05-02\Capture\Light\14_53_15Z_.ser (1000 frames)
    Splitting frames at brightness threshold of 125.00
    100 frames...
    200 frames...
    300 frames...
    400 frames...
    500 frames...
    600 frames...
    700 frames...
    800 frames...
    900 frames...
    1000 frames...
    512 frames below threshold written to C:\Users\robin\Desktop\SharpCap Captures\2025-05-02\Capture\Light\14_53_15Z__04_22_38_dim.ser
    488 frames above threshold written to C:\Users\robin\Desktop\SharpCap Captures\2025-05-02\Capture\Light\14_53_15Z__04_22_38_bright.ser
    
  • That's it - you now have two separate SER files for the two brightness levels. These will now need further manual processing, particularly to split them at the 'jump' points where the exposure changed then changed back if you are trying to make an HDR video animation
Option 2 - SerSplit 1.01

This version of SerSplit is more advanced and can do more things, but is a bit more complex to use. As well as producing the two file (dim/bright) output that the older SerSplit version can, it can also produce a 'multi' chunk output, splitting the output file every time the exposure is changed from dim to bright or bright to dim - the instructions below focus on that latter option.
  • Download SERSplit.zip from https://downloads.sharpcap.co.uk/tools/ ... t_1.01.zip
  • Unzip SERSplit.zip to get the executable file - SERSplit.exe inside
  • Open a windows command prompt and enter a command like the one below

    Code: Select all

    C:\Users\robin\Downloads\SerSplit_1.01\SerSplit.exe -i "C:\Users\robin\Desktop\SharpCap Captures\2025-05-02\Capture\Light\14_53_15Z_.ser" -m 10
    
    The first part specifies where the SerSplit.exe file can be found and the second specifies the SER file to process. The easiest way to get those full files and paths into the windows command prompt is to drag first the .exe file into the command prompt box, then add a space, then drag in the .SER file. Dragging files into a command prompt inserts the full path to the file, which is just what we want here... Note the -i option which specifies that the next thing on the command line is the input file to read and the '-m 10' option, which specifies that we want multi-chunk ouptut with a minimum of 10 frames in each chunk of output file.

    This command will do everything - no need to run the program twice for analysis then splitting as with the older version (although you can still do it that way if you want - use the -scan option to analyse and the -t to specify your own threshold).
  • The output from the command will be something like this

    Code: Select all

    Reading C:\Users\robin\Desktop\SharpCap Captures\2025-05-02\Capture\Light\14_53_15Z_.ser (1000 frames)
    Threshold between bright and dim frames estimated at 121.35
    Reading C:\Users\robin\Desktop\SharpCap Captures\2025-05-02\Capture\Light\14_53_15Z_.ser (1000 frames)
    Splitting frames at brightness threshold of 121.35
    100 frames...
    200 frames...
    300 frames...
    400 frames...
    500 frames...
    600 frames...
    700 frames...
    800 frames...
    900 frames...
    1000 frames...
    512 frames below threshold written to C:\Users\robin\Desktop\SharpCap Captures\2025-05-02\Capture\Light\14_53_15Z__split_at_04_40_54_dim_[0..22].ser
    488 frames above threshold written to C:\Users\robin\Desktop\SharpCap Captures\2025-05-02\Capture\Light\14_53_15Z__split_at_04_40_54_dim_[0..23].ser
    
    Note that the application reads the input file twice - first to estimate the threshold to use, then to do the actual splitting on the second reading of the file. The estimated threshold was 121.35 - pretty close to the value of 125 that we estimated for the older version of SerSplit above.
  • Because of the use of the -m option, there are multiple files for both the dim and bright parts of the HDR - in this case 23 'dim' segments (numbered 0 to 22) and 24 bright segments (0 to 23). Each file will contain a single block of either dim or bright frames.
And then...

Once the HDR SER file has been split into dim and bright chunks using one of the tools above, processing can be more-or-less as usual for stacking of frames, followed by an HDR merge to combine the two separate dim and bright images into a single HDR image.

cheers,

Robin
User avatar
admin
Site Admin
Posts: 15380
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: ISS Imaging in HDR using SharpCap

#3

Post by admin »

HDR Processing workflow by Charline Giroud

Crop and stabilise the target with PIPP
The first step after splitting the data into dim and bright files is to generate data compatible with Autostakkert for stacking which will be recombined using HDR composition. To do so, the target has to be stabilised and reframed using PIPP and the dedicated ISS options and save the data in png, tif or ser format. Process both (dim and bright) files in parallel.
image5.png
image5.png (14.54 KiB) Viewed 114 times
image4.png
image4.png (264.18 KiB) Viewed 114 times
image3.png
image3.png (110.44 KiB) Viewed 114 times

Stack the sequences
Stack the stabilised and cropped data by using Autostakkert. Use the expand option to slice the set of data so that a few seconds are stacked at once. This is to avoid artefact due to the rotation of the ISS along the time.
The frame rate at the acquisition was 120 fps, with 60 dim and 60 bright frames per second. Here, we want to stack 3 seconds of data, 180 frames to stack, and 90 frames between each slice (1.5 seconds). Click “expand”, “analyse”, place the anchor points (AP) and then “Stack”.
Process both (dim and bright) files in parallel.
image1.png
image1.png (55.92 KiB) Viewed 114 times
image8.png
image8.png (129 KiB) Viewed 114 times

Align the dim/bright images
The next step is the alignment of the final dim and bright stacks before the HDR composition. This step is essential as the stack files don’t overlap perfectly due to the apparent rotation of the ISS as it moves overhead, and this effect might not be compatible with HDR processing of pairs of dim/bright images.
image6.png
image6.png (266.7 KiB) Viewed 113 times
Download the ImageAlign tool from https://downloads.sharpcap.co.uk/tools/ImageAlign.zip, then unzip to extract the ‘ImageAlign.exe’ application. This is a Windows command line application, so you will need to start a Windows command prompt to run the application correctly. For the purposes of this demo, let’s assume that the ImageAlign tool is unzipped to c:\ImageAlign\ImageAlign.exe

Pick a pair of dim/bright image files to test with - let’s assume that those files are saved at c:\iss\dim_0001.png and c:\iss\bright_0001.png.

From the command prompt, run this command

Code: Select all

c:\ImageAlign\ImageAlign.exe -r c:\iss\dim_0001.png -t c:\iss\bright_0001.png
This tells ImageAlign that the reference image is the dim_0001.png image and the target image that needs to be aligned with the reference image is the bright_0001.png image. ImageAlign will try aligning the two images at different rotations (testing rotations every 0.1 degrees from -3 to +3 degrees) to find the angle of the best match. Once the best angle is found, ImageAlign will save an output file to c:\iss_bright_0001.aligned.png, which is a new copy of the target file that has been rotated and offset to give best alignment with the reference file.
image2.png
image2.png (46.27 KiB) Viewed 113 times
image7.png
image7.png (47.23 KiB) Viewed 113 times

If you are making an animation and have many pairs of dim & bright files to align, it would be tedious to do each pair by hand - fortunately there is no need to - modify the command to run as follows

Code: Select all

c:\ImageAlign\ImageAlign.exe -r c:\iss\dim_*.png -t c:\iss\bright_*.png
Using ‘*’ or ‘?’ wildcard characters in the names of the files will make ImageAlign process all files found matching those wildcards in pairs - for instance dim_0001.png with bright_0001.png, dim_0002.png with bright_0002.png, etc. Note that a ‘?’ matches any single character, a ‘*’ matches any number of characters.

Note: If the file names or folder names of the image files, or the ImageAlign.exe application contain spaces or other special characters, you may need to enclose those file/folder names in double quotes - like this:

Code: Select all

"c:\Image Align\ImageAlign.exe" -r "c:\iss\dim_*.png" -t "c:\iss\bright_*.png"

HDR combination

Now, the stacked files are ready to be combined using a HDR composition tool.
Open HDR composition in PixInsight and load the files you want to combine, click the circle to start the process, the HDR version (bottom right) made of the linear part of the dim and bright (top) files is generated. This tool also generates the mask used for the HDR combination (bottom left).
image9.png
image9.png (493.38 KiB) Viewed 113 times
Other processing can be applied to the HDR image like sharpen or deconvolution.
User avatar
turfpit
Posts: 1945
Joined: Mon Feb 13, 2017 8:13 pm
Location: UK
Contact:

Re: ISS Imaging in HDR using SharpCap

#4

Post by turfpit »

Impressive!

Dave
Post Reply