Created
December 9, 2024 00:00
-
-
Save soswow/bfc4d143da97d4a378d853e13004a6f2 to your computer and use it in GitHub Desktop.
Some bash scripts used in my focus stacking process
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Grouping pictures into folder by count (6 in this case) | |
counter=0; group_number=1; for img in *.jpg; do [[ -e "$img" ]] || continue; if (( counter % 6 == 0 )); then mkdir -p "group_$group_number"; ((group_number++)); fi; mv "$img" "group_$((group_number-1))"; ((counter++)); done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Path to Hugin tools | |
HUGIN_TOOLS="/Applications/Hugin/tools_mac" | |
# Iterate over subfolders | |
for folder in */; do | |
# Handle spaces in folder names | |
folder="${folder%/}" | |
# Create a directory for aligned images | |
aligned_folder="$folder/aligned" | |
mkdir -p "$aligned_folder" | |
# Align images using align_image_stack (case-insensitive match for jpg and JPG) | |
"$HUGIN_TOOLS/align_image_stack" -m -a "$aligned_folder/aligned_" "$folder"/*.jpg | |
# Perform focus stacking using Enfuse | |
"$HUGIN_TOOLS/enfuse" --saturation-weight=0 --exposure-weight=0 --contrast-weight=0.08 --gray-projector=luminance --contrast-window-size=3 --output="${folder}_stacked.jpg" "$aligned_folder/"*.tif | |
# Clean up temporary TIFF files (optional) | |
rm "$aligned_folder"/*.tif | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# An example script I've used to test various settings of enfuse to see what works best | |
# It iterates over some values (For one parameter) and geneates masks (converts them to png) so that you can take a look | |
for contrast_weight in $(seq 0.1 0.1 0.9); do /Applications/Hugin/tools_mac/enfuse --saturation-weight=0 --exposure-weight=0 --contrast-weight="$contrast_weight" --gray-projector="luminance" --contrast-window-size=3 --save-masks="mask-test-weight-${contrast_weight}.tif" "/Users/sasha/Creative/Photogrammetry/photostacking test/set 1/0A1A8152.JPG" && magick "mask-test-weight-${contrast_weight}.tif" -depth 8 -channel RGB -fx "round(255 * r)" "mask-test-weight-${contrast_weight}.png" && rm "mask-test-weight-${contrast_weight}.tif"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment