-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasterism
2259 lines (1747 loc) · 56.1 KB
/
asterism
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#ifs.sh
# Acknowledgements
# Ivo Jaeger (http://siliconfields.net)
# dcraw: (http://www.cybercom.net/~dcoffin/)
# Demosaic / DeBayer: (http://www.ipol.im/pub/art/2011/g_mhcd/)
# ImageMagick: (http://www.imagemagick.org/script/index.php)
# Panotools: (http://panotools.sourceforge.net/)
# Hugin: (http://hugin.sourceforge.net/)
# Macrofusion: (https://sourceforge.net/projects/macrofusion/)
# Fred's ImageMagick scripts: (http://www.fmwconcepts.com)
# Linux / xubuntu: (https://xubuntu.org/)
# Asterism - An astronomical exposure reduction image stacking method - for consumer digital cameras
# Copyright (C) 2015 - 2017 Rowland Cheshire
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
# location of Asterism source files - negotiate Desktop link to /home/Asterism
# get path to asterism
MYPATH="`dirname \"$0\"`" # relative
MYPATH="`( cd \"$MYPATH\" && pwd )`" # absolutized and normalized
if [ -z "$MYPATH" ] ; then
# error; for some reason, the path is not accessible
# to the script (e.g. permissions re-evaled after suid)
exit 1 # fail
fi
echo $MYPATH
# location of source files
# if [ -e $MYPATH/asterism ]; then
source=$(readlink -f $MYPATH)
## fi
# no AT bridge
export NO_AT_BRIDGE=1
# Asterism and package installation check
DESKTOP=$DESKTOP_SESSION
# Asterism version
Asterism_version=$'Asterism_0.1.5.1'
# title
title='Asterism'
# show current time
time=$(zdump UTC)
# get distro vendor
vendor=$(lsb_release -i) >/dev/null 2>&1
# show file system info
space=$(df -l -h ~/)
# system memory
sysmem=$(free -m | awk '/^Mem:/{ print $2 }')
# OSX friendly get number of processors
cores=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu)
if [ $cores == 1 ]; then
defaultcores=1; else
((defaultcores=$cores - 1))
fi
# cores=$(getconf _NPROCESSORS_ONLN)
# location of help file
if [ -e $MYPATH/utils/help.txt ]; then
help=$(readlink -f $MYPATH/utils/help.txt)
fi
# location of splash image
if [ -e $MYPATH/utils/AsterismLOGOsplash.png ]; then
splash=$(readlink -f $MYPATH/utils/AsterismLOGOsplash.png)
fi
# location of yad window icon
if [ -e $MYPATH/utils/AsterismLOGOs.png ]; then
wicon=$(readlink -f $MYPATH/utils/AsterismLOGOs.png)
fi
# create directory (if needed) helper function
function createDirIfNeeded ()
{
if [ -d $1 ]
then
echo " " >/dev/null 2>&1
else
echo " Create $1 folder"
mkdir $1
fi
}
# file type function
function fileType ()
{
files=$(basename -a *.*)
ext="${files##*.}"
}
# function - number of files in folder
function numFiles ()
{
f=$(find . -type f | wc -l)
}
# yad progress function
function yadProgress ()
{
yad --progress --center \
--title="$title - $name" \
--progress-text="$text" \
--window-icon=$wicon \
--width=300 \
--pulsate \
--no-buttons \
--auto-close \
--auto-kill 2>/dev/null
}
# yad error function
function yadError ()
{
ret=$?; (( $ret != 0 )) && yad --error --text="Error in yad command"
}
# mean stack function
function meanStack ()
{
convert *.tif -depth $depth -evaluate max $qrmax% -evaluate min $qrmin% -evaluate-sequence mean stack_$name.tif >/dev/null 2>&1
}
# clean up function
function cleanUp ()
{
rm -f -R $tmpdir $imagedir/.magick
}
# function - killall
function killAll ()
{
killall asterism awk yad convert display
}
# create ~/.asterism directory
createDirIfNeeded ~/.asterism
# location of log file
log=~/.asterism/log
# image session info log file
project_log=~/.asterism/project_log
# resources log file
syslog=~/.asterism/syslog
# camera log
add_cam=~/.asterism/add_cam
# camera channel list multiple cameras
cam_list=~/.asterism/cam_list
touch $cam_list
# camera channel list edited
new_cam_list=~/.asterism/new_cam_list
touch $new_cam_list
# camera and channel selection and configuration log
multi_log=~/.asterism/multi_log
# no config
noconfig=~/.asterism/noconfig
createDirIfNeeded $noconfig
# yad notebook plug key
key=$RANDOM
# splash screen
# yad --no-buttons --undecorated --center --image=$splash --timeout=1 2>/dev/null
# camera list variables
cam1=$(awk 'NR==1 { print $1 }' "$cam_list")
cam2=$(awk 'NR==2 { print $1 }' "$cam_list")
cam3=$(awk 'NR==3 { print $1 }' "$cam_list")
cam4=$(awk 'NR==4 { print $1 }' "$cam_list")
cam5=$(awk 'NR==5 { print $1 }' "$cam_list")
# documentation tab
yad --plug=$key --tabnum=7 --text-info < $help --show-uri \
--fontname="Georgia 11" \
--wrap \
--justify=fill \
--margins=10 \
--auto-close \
--auto-kill &> res7 &
# system management tab
yad --plug=$key --tabnum=6 --form --columns=2 --editable --separator=':' \
--text="$Asterism_version - Copyright (c) 2017 (cheshire_r@fastmail.fm).
This program comes with ABSOLUTELY NO WARRANTY. This is free software and you are welcome to redistribute it under certain conditions - GPLv3.
$space Source Files $source $vendor
" \
--field="Processors":RO \
"$cores" \
--field="ImageMagick threads":NUM \
"$defaultcores"!1.."$cores"!1!0 \
--field="Memory":RO \
"$sysmem" \
--field="ImageMagick memory limit %":SCL \
'50!10..100!1!0' > $syslog | &> res6 &
# project details tab
yad --plug=$key --tabnum=5 --form --columns=3 --separator=':' \
--text="Record project details
" \
--field="Free Text" \
'' \
--field="Astrophotographer" \
'Name' \
--field="Location" \
'Dark Site' \
--field="Date of Acquisition":DT \
'DD/MM/YY' \
--field="Camera" \
'Make Model' \
--field="Cooling" \
'Temperature C/F' \
--field="Lens or Telescope" \
'Make Model' \
--field="Focal Length Aperture" \
'MM f/' \
--field="Mount" \
'Make Model' \
--field="Guiding" \
'Software Hardware' \
--field="Light Frames" \
'Number Exposure Time ISO' \
--field="Calibration Frames" \
'Bias Dark Flat' \
--field="UTC":RO \
"$time" | awk 'BEGIN { FS = ":" } ; { print $0 }' > $project_log | &> res5 &
# edit camera list
yad --plug=$key --tabnum=4 --text-info --separator=':' --editable < $cam_list > $new_cam_list | &> res4 &
# add camera RGB channel multiplier matrix
yad --plug=$key --tabnum=3 --form --columns=4 --separator=':' \
--text="Generate RGB channel multiplier matrix" \
--field='Camera' \
'-' \
--field="":RO \
'' \
--field="":RO \
'' \
--field="RR":NUM \
'0!-2..2!0.01!2' \
--field="GR":NUM \
'0!-2..2!0.01!2' \
--field="BR":NUM \
'0!-2..2!0.01!2' \
--field="RG":NUM \
'0!-2..2!0.01!2' \
--field="GG":NUM \
'0!-2..2!0.01!2' \
--field="BG":NUM \
'0!-2..2!0.01!2' \
--field="RB":NUM \
'0!-2..2!0.01!2' \
--field="GB":NUM \
'0!-2..2!0.01!2' \
--field="BB":NUM \
'0!-2..2!0.01!2' | awk 'BEGIN { FS = ":" } ; { print $0 }' > $add_cam | &> res3 &
# camera channel multiplier application
yad --plug=$key --tabnum=2 --form --columns=2 --separator=':' \
--text="Select camera and channel multiplier matrix sequence - pre or post image stack" \
--field="Camera":CB \
"$cam1"!"$cam2"!"$cam3"!"$cam4"!"$cam5" \
--field="Channel multipliers":CB \
'NONE!PRESTACK!POSTSTACK' | awk 'BEGIN { FS = ":" } ; { print $0 }' > $multi_log | &> res2 &
# preprocessing options tab
yad --plug=$key --tabnum=1 --form --separator=':' --columns=2 \
--text="<b>Select project (output) folder, processes and options</b>
" \
--field="<b>Project folder*</b>":DIR \
"$noconfig" \
--field="<b>Input format</b>":CB \
'RAW!OTHER!OTHER BAYER' \
--field="<b>Output format</b>" \
'tif' \
--field="<b>Colour depth</b>":CB \
'16!8!24!32!48!64!' \
--field="<b>Master frames - create new</b>":BTN \
'' \
--field="Map defects":CHK \
'TRUE!FALSE' \
--field="Bias frames":CHK \
'TRUE!FALSE' \
--field="- Super-bias":CHK \
'TRUE!FALSE' \
--field="- Median":CHK \
'TRUE!FALSE' \
--field="Dark frames":CHK \
'TRUE!FALSE' \
--field="- Median":CHK \
'TRUE!FALSE' \
--field="Flat frames":CHK \
'TRUE!FALSE' \
--field="- Median":CHK \
'TRUE!FALSE' \
--field="Flat correction":NUM \
'5!1..75!0.1!1' \
--field="<b>Master frames - select templates</b>":BTN \
'' \
--field="Defect map":FL \
'-' \
--field="Master bias":FL \
'-' \
--field="Master dark":FL \
'-' \
--field="Master flat":FL \
'-' \
--field="<b>Image reduction - calibrate light frames</b>":BTN \
'' \
--field="Light frames":CHK \
'TRUE!FALSE' \
--field="<b>Reserved</b>":BTN \
'' \
--field="<b>Image integration - alignment and stacking</b>":BTN \
'' \
--field="DeBayer align and stack":CHK \
'TRUE!FALSE' \
--field="<b>Noise filters</b>":BTN \
'' \
--field="Noise - radius":NUM \
'0!0..30!1!0' \
--field="Noise - amount":NUM \
'0!0..5!0.01!2' \
--field="QRMax":NUM \
'0!0..5!0.000001!6' \
--field="QRMin":NUM \
'100!0..100!0.000001!6' \
--field="<b>DeBayer options</b>":BTN \
'' \
--field="DeBayer":CB \
'BILINEAR!MALVAR!SUPERPIXEL' \
--field="Bayer matrix":CB \
'RGGB!BGGR!GRBG!GBRG' \
--field="<b>Align and stack options</b>":BTN \
'' \
--field="Interface":CB \
'SYSTEM!HUGIN!MACROFUSION' \
--field="Alignment":CB \
'LINEAR!MULTI!ALL PAIRS' \
--field="Stack":CB \
'POLYNOMIAL!MEAN!MEDIAN!ENFUSE' \
--field="Ransac":NUM \
'200' \
--field="HFOV":NUM \
'8' \
--field="Cache":NUM \
'4096' \
--field="Mask":CB \
'NONE!SOFT!HARD' \
--field="<b>Colour processing</b>":BTN \
'' \
--field="RAW colour images":CHK \
'TRUE!FALSE' \
--field="Sketch":CHK \
'TRUE!FALSE' \
--field="Demosaic":CB \
'XTRANS!AHD!BILINEAR!FOUR COLORS!HALF SIZE!PPG!VNG' > $log | &> res1 &
# run main notebook dialog
yad --notebook --key=$key --center --tab="<b>Process and options</b>" --tab="<b>Select camera matrix</b>" --tab="<b>Add camera matrix</b>" --tab="<b>Edit camera list</b>" --tab="<b>Project details</b>" --tab="<b>System settings</b>" --tab="<b>Documentation</b>" \
--text="<span foreground='grey'><b><big>$Asterism_version</big></b></span>" \
--title="Asterism" \
--window-icon=$wicon \
--image=$wicon \
--image-on-top \
--buttons-layout=spread \
--button=Quit:1 \
--button='Files:bash -c "yad --file --center --save --title="Files" --height=600 --width=450"' \
--button='Convert:bash -c "./utils/conversion"' \
--button='Inspect:bash -c "./utils/inspect"' \
--button='PMStack:bash -c "./utils/pmstack"' \
--button='Hugin: hugin' \
--button='Histogram:bash -c "./utils/histogram"' \
--button=Process:0 2>/dev/null
# run quit asterism
ret=$?
if [[ $ret = 1 || $ret = 252 ]]; then
killAll
rm -f $source/res*
exit 1; else
echo " " >/dev/null 2>&1
fi
{ IFS=':' read directory raw format depth blank1 defect bias superbias medbias dark meddark flat medflat autof blank2 defectmap masterbias masterdark masterflat blank3 light reserved blank4 process blank5 radius amount qrmax qrmin blank6 debayer matrix blank7 interface cpoint stack ransac hfov cache mask blank8 color sket demos; } < $log
# get the project name from the project directory
name=$(basename $directory)
echo " Project name $name
Project directory $directory
Input format $raw
Output format $format
Depth $depth
Map defects $defect
Bias frames $bias
Superbias $superbias
Median bias $medbias
Dark frames $dark
Median dark $meddark
Flat frames $flat
Median flat $medflat
Flat correction $autof
Defect map $defectmap
Master bias $masterbias
Master dark $masterdark
Master flat $masterflat
Light frames $light
Reserved $reserved
Process $process
Radius $radius
Amount $amount
QRMax $qrmax
QRMin $qrmin
Debayer $debayer
Matrix $matrix
Interface $interface
Align $cpoint
Stack $stack
Ransac $ransac
HFOV $hfov
Cache $cache
Mask $mask
Colour $color
Sketch $sket
Demosaic $demos"
# imagemagick in-built resources - processing threads and memory allocation
{ IFS=":" read processors threads memory memlimit; } < $syslog
export MAGICK_THREAD_LIMIT=$threads
magickmem=$(echo "scale=0; $sysmem/100*$memlimit" | bc)
export MAGICK_MEMORY_LIMIT=$magickmem'MiB'
((maplimit=$sysmem/4))
export MAGICK_MAP_LIMIT=$maplimit'MiB'
echo "
ImageMagick resources
Using $threads of $cores threads and $magickmem of "$sysmem"MB or "$memlimit"% of memory
Map limit = "$maplimit"MB"
echo "File loading and preprocessing"
# add camera RGB channel matrix file
mv $new_cam_list $cam_list
noaddcam=$(awk 'BEGIN { FS = ":" } ; { print $1 }' $add_cam)
if [ "$noaddcam" = "-" ]; then
echo " " >/dev/null 2>&1; else
awk 'BEGIN { FS = ":" } ; { print $1,$4,$5,$6,$7,$8,$9,$10,$11,$12 }' $add_cam | tee -a $cam_list
fi
rm $add_cam
# channel multiplier camera and variables
camera=$(awk 'BEGIN { FS = ":" } ; { print $1 }' camera=$1 $multi_log)
multi=$(awk 'BEGIN { FS = ":" } ; { print $2 }' multi=$2 $multi_log)
if [ "$camera" = "$cam1" ]; then
Rr=$(awk 'NR==1 { print $2 }' $cam_list)
Gr=$(awk 'NR==1 { print $3 }' $cam_list)
Br=$(awk 'NR==1 { print $4 }' $cam_list)
Rg=$(awk 'NR==1 { print $5 }' $cam_list)
Gg=$(awk 'NR==1 { print $6 }' $cam_list)
Bg=$(awk 'NR==1 { print $7 }' $cam_list)
Rb=$(awk 'NR==1 { print $8 }' $cam_list)
Gb=$(awk 'NR==1 { print $9 }' $cam_list)
Bb=$(awk 'NR==1 { print $10 }' $cam_list)
else
if [ "$camera" = "$cam2" ]; then
Rr=$(awk 'NR==2 { print $2 }' $cam_list)
Gr=$(awk 'NR==2 { print $3 }' $cam_list)
Br=$(awk 'NR==2 { print $4 }' $cam_list)
Rg=$(awk 'NR==2 { print $5 }' $cam_list)
Gg=$(awk 'NR==2 { print $6 }' $cam_list)
Bg=$(awk 'NR==2 { print $7 }' $cam_list)
Rb=$(awk 'NR==2 { print $8 }' $cam_list)
Gb=$(awk 'NR==2 { print $9 }' $cam_list)
Bb=$(awk 'NR==2 { print $10 }' $cam_list)
else
if [ "$camera" = "$cam3" ]; then
Rr=$(awk 'NR==3 { print $2 }' $cam_list)
Gr=$(awk 'NR==3 { print $3 }' $cam_list)
Br=$(awk 'NR==3 { print $4 }' $cam_list)
Rg=$(awk 'NR==3 { print $5 }' $cam_list)
Gg=$(awk 'NR==3 { print $6 }' $cam_list)
Bg=$(awk 'NR==3 { print $7 }' $cam_list)
Rb=$(awk 'NR==3 { print $8 }' $cam_list)
Gb=$(awk 'NR==3 { print $9 }' $cam_list)
Bb=$(awk 'NR==3 { print $10 }' $cam_list)
else
if [ "$camera" = "$cam4" ]; then
Rr=$(awk 'NR==4 { print $2 }' $cam_list)
Gr=$(awk 'NR==4 { print $3 }' $cam_list)
Br=$(awk 'NR==4 { print $4 }' $cam_list)
Rg=$(awk 'NR==4 { print $5 }' $cam_list)
Gg=$(awk 'NR==4 { print $6 }' $cam_list)
Bg=$(awk 'NR==4 { print $7 }' $cam_list)
Rb=$(awk 'NR==4 { print $8 }' $cam_list)
Gb=$(awk 'NR==4 { print $9 }' $cam_list)
Bb=$(awk 'NR==4 { print $10 }' $cam_list)
else
if [ "$camera" = "$cam5" ]; then
Rr=$(awk 'NR==5 { print $2 }' $cam_list)
Gr=$(awk 'NR==5 { print $3 }' $cam_list)
Br=$(awk 'NR==5 { print $4 }' $cam_list)
Rg=$(awk 'NR==5 { print $5 }' $cam_list)
Gg=$(awk 'NR==5 { print $6 }' $cam_list)
Bg=$(awk 'NR==5 { print $7 }' $cam_list)
Rb=$(awk 'NR==5 { print $8 }' $cam_list)
Gb=$(awk 'NR==5 { print $9 }' $cam_list)
Bb=$(awk 'NR==5 { print $10 }' $cam_list)
fi
fi
fi
fi
fi
# enfuse mask variables
if [ "$mask" = "NONE" ]; then
MASK=""; else
if [ "$mask" = "SOFT" ]; then
MASK=--soft-mask; else
if [ "$mask" = "HARD" ]; then
MASK=--hard-mask; else
echo " " >/dev/null 2>&1
fi
fi
fi
# alignment control point variable
if [ "$cpoint" = "LINEAR" ]; then
CPOINT=--linearmatch; else
if [ "$cpoint" = "MULTI" ]; then
CPOINT=--multirow; else
if [ "$cpoint" = "ALL PAIRS" ]; then
CPOINT=""; else
echo " " >/dev/null 2>&1
fi
fi
fi
# Demosaic (demosaic) options
if [ "$demos" = "FOUR COLORS" ]; then
q=-f; else
if [ "$demos" = "HALF SIZE" ]; then
q=-h; else
q=-q
fi
fi
if [ "$demos" = "BILINEAR" ]; then
DEMOS=0; else
if [ "$demos" = "VNG" ]; then
DEMOS=1; else
if [ "$demos" = "PPG" ]; then
DEMOS=2; else
if [ "$demos" = "AHD" ]; then
DEMOS=3; else
if [ "$demos" = "XTRANS" ]; then
DEMOS=4; else
echo " " >/dev/null 2>&1
fi
fi
fi
fi
fi
# set up paths and other environment variables
tmpdir=$imagedir/.tmp
masterdir=$imagedir/master
tmpfdir=$imagedir/.tmp/tmpf
tmpldir=$imagedir/.tmp/tmpl
rejectdir=$imagedir/rejects
previewdir=$imagedir/.preview
stagingdir=~/.asterism/staging
llrgbdir=$imagedir/llrgb_$name
processdir=$imagedir/process_$name
debaydir=$imagedir/process_$name/debayer_$name
# look for dcraw RAW convertor
if [[ -x /usr/bin/dcraw || -x /usr/local/bin/dcraw ]]; then
echo " " >/dev/null 2>&1;
else
yad --question --window-icon=$wicon --width=300 --title="$title - Install dcraw" --text="Install dcraw?" --button="Quit - install dcraw":1 2>/dev/null
ret=$?; if [ $ret = 1 ]; then
killAll
rm -f $source/res*
exit 1
fi
fi
# look for imagemagick - imagemagick 7 proof
if [[ -x /usr/bin/convert-im6 || -x /usr/bin/magick || -x /usr/local/bin/magick ]]; then
echo " " >/dev/null 2>&1;
else
yad --question --window-icon=$wicon --width=300 --title="$title Install ImageMagick" --text="Install ImageMagick?" --button="Quit - install imagemagick":1 2>/dev/null
ret=$?; if [ $ret = 1 ]; then
killAll
rm -f $source/res*
exit 1
fi
fi
# look for align_image_stack - image registration - likely to be installed as a dependency for macrofusion and hugin
if [[ -x /usr/bin/align_image_stack ]]; then
echo " " >/dev/null 2>&1;
else
yad --question --window-icon=$wicon --width=300 --title="$title Install hugin-tools" --text="Install hugin-tools?" --button="Quit - install hugin-tools":1 2>/dev/null
ret=$?; if [ $ret = 1 ]; then
killAll
rm -f $source/res*
exit 1
fi
fi
# look for enfuse - image registration - likely to be installed as a dependency for macrofusion and hugin
if [[ -x /usr/bin/align_image_stack ]]; then
echo " " >/dev/null 2>&1;
else
yad --question --window-icon=$wicon --width=300 --title="$title Install Enfuse" --text="Install Enfuse?" --button="Quit - install enfuse":1 2>/dev/null
ret=$?; if [ $ret = 1 ]; then
killAll
rm -f $source/res*
exit 1
fi
fi
# look for macrofusion - image integration
if [ "$interface" != "MACROFUSION" ] && [ -x /usr/bin/macrofusion ]; then
echo " " >/dev/null 2>&1; else
if [ "$interface" = "MACROFUSION" ] && [ ! -x /usr/bin/macrofusion ]; then
yad --question --window-icon=$wicon --width=300 --title="$title - Install MacroFusion" --text="Install MacroFusion?" --button="Quit - install macrofusion":1 --button=Yes:0 2>/dev/null
ret=$?; if [ $ret = 1 ]; then
killAll
rm -f $source/res*
exit 1
fi
fi
fi
# look for hugin - image integration
if [ "$interface" != "HUGIN" ] && [ -x /usr/bin/hugin ]; then
echo " " >/dev/null 2>&1; else
if [ "$interface" = "HUGIN" ] && [ ! -x /usr/bin/hugin ]; then
yad --question --window-icon=$wicon --width=300 --title="$title - Install Hugin" --text="Install Hugin?" --button="Quit - install Hugin":1 2>/dev/null
ret=$?; if [ $ret = 1 ]; then
killAll
rm -f $source/res*
exit 1
fi
fi
fi
# no project directory
if [ "$directory" != "$noconfig" ]; then
echo " " >/dev/null 2>&1; else
text=$(echo "Return to Asterism - Please select project folder")
echo " Return to Asterism - Please select project folder"
(
echo ""
) |
yad --progress --center \
--title="$title - noconfig" \
--progress-text="$text" \
--window-icon=$wicon \
--width=300 \
--pulsate \
--no-buttons \
--timeout=1 2>/dev/null
rm -f -R $noconfig
cleanUp
killAll
if [ -e $MYPATH/asterism ]; then
bash -x ./asterism
fi
exit
fi
# create staging directory
createDirIfNeeded $stagingdir
# No master frame warning - return to Asterism
if [ "$defect" != "TRUE" ] && [ "$bias" != "TRUE" ] && [ "$dark" != "TRUE" ] && [ "$flat" != "TRUE" ] && [ "$light" != "TRUE" ] && [ "$color" != "TRUE" ] && [ "$sket" != "TRUE" ]; then
text=$(echo "No frames selected - Return to Asterism")
echo " No frames selected - Return to Asterism"
(
echo ""
) |
yad --progress --center \
--title="$title - No frames selected" \
--progress-text="$text" \
--window-icon=$wicon \
--width=300 \
--pulsate \
--no-buttons \
--timeout=1 2>/dev/null
cleanUp
killAll
if [ -e $MYPATH/asterism ]; then
bash -x ./asterism
fi
exit
fi
if [ "$light" = "TRUE" ] && [ "$defect" != "TRUE" ] && [ ! -e "$defectmap" ] && [ "$bias" != "TRUE" ] && [ ! -e "$masterbias" ] && [ "$dark" != "TRUE" ] && [ ! -e "$masterdark" ] && [ "$flat" != "TRUE" ] && [ ! -e "$masterflat" ]; then
yad --info --center \
--title="$title - Master frame selection warning - $name" \
--text="Light frames are marked for preprocessing. No bias dark defect map and flat frames have been selected
If master frames were not created for this project, please consider the following options;
1. Continue - light frames will not be calibrated
2. Return - return to the Asterism interface and select the desired calibration frames
a. Master frames may be created on-the-fly in train with light frames; or
b. Previously created master frames may be selected individually; or
c. Use existing master frames as well as creating master frames on-the-fly
For best light frame calibration results, a minimum of master bias, master flat (and defect map - preferably) is recommended
Note: Asterism will accomodate any combination of master frame selection but dark frames are excluded where master bias or defect map is used for light frame calibration" \
--window-icon=$wicon \
--width=500 \
--button=Return:0 \
--button=Continue:1 2>/dev/null
ret=$?; if [ $ret = 1 ]; then
echo " " >/dev/null 2>&1; else
text=$(echo "Returning to Asterism")
echo "Returning to Asterism"
(
echo ""
) |
yad --progress --center \
--title="$title - $name" \
--progress-text="$text" \
--window-icon=$wicon \
--width=300 \
--pulsate \
--no-buttons \
--timeout=1 2>/dev/null
cleanUp
killAll
if [ -e $MYPATH/asterism ]; then
bash -x ./asterism
fi
exit
fi
fi
# RAW COLOUR PROCESSING - align stack colour bracketed / HDR exposures
if [ "$color" != "TRUE" ]; then
echo " " >/dev/null 2>&1; else
IFS=$'\n'
files=($(yad --file-selection --center --window-icon=$wicon --height=600 --width=480 --title="$title - Colour images $name" --text="Select images" --button=Skip:1 --button=Load:0 --multiple --separator=$'\n' 2>/dev/null))
echo "${files[@]}" 2>/dev/null
imagedir=`echo "$files" |xargs dirname`
echo $imagedir
if [ -e "$directory/project_details_$name" ]; then
echo " " >/dev/null 2>&1; else
awk 'BEGIN { FS = ":" } ; { print $0 }' $project_log | tee -a $directory/project_details_$name
fi
export MAGICK_TEMPORARY_PATH="$imagedir/.magick"
createDirIfNeeded $MAGICK_TEMPORARY_PATH
logname=$directory/log_$name 2>/dev/null
cp $log $logname 2>/dev/null
processdir=$directory/process_$name
debaydir=$directory/debayer_$name
llrgbdir=$directory/llrgb_$name
# createDirIfNeeded $processdir
rm -f -R $processdir
createDirIfNeeded $processdir
createDirIfNeeded $debaydir
text=$(echo "Colour processing")
echo "Colour processing"
(
echo ""
for i in `ls -v ${files[@]}`; do dcraw -4 -o 1 $q $DEMOS -t 0 -H 1 -T $i; done
x=(0)
for i in `ls -v $imagedir/*.tiff`; do convert $i $processdir/$((x++))_$name.miff; done
rm -f $imagedir/*.tiff
x=(0)
for i in `ls -v $processdir/*.miff`; do convert $i $processdir/$((x++))_$name.tiff; done
rm -f $processdir/*.miff
) |
yadProgress
yadError
fi
# SKETCH
if [ "$sket" != "TRUE" ]; then
echo " " >/dev/null 2>&1; else
IFS=$'\n'
files=($(yad --file-selection --center --window-icon=$wicon --height=600 --width=480 --title="$title - Sketch $name" --text="Select images" --button=Skip:1 --button=Load:0 --multiple --separator=$'\n' 2>/dev/null))
echo "${files[@]}" 2>/dev/null
imagedir=`echo "$files" |xargs dirname`
echo $imagedir
if [ -e "$directory/project_details_$name" ]; then
echo " " >/dev/null 2>&1; else
awk 'BEGIN { FS = ":" } ; { print $0 }' $project_log | tee -a $directory/project_details_$name
fi
export MAGICK_TEMPORARY_PATH="$imagedir/.magick"
createDirIfNeeded $MAGICK_TEMPORARY_PATH
logname=$directory/log_$name 2>/dev/null
cp $log $logname 2>/dev/null
sketchdir=$directory/Sketch_$name
# createDirIfNeeded $sketchdir
createDirIfNeeded $sketchdir
text=$(echo "Sketch")
echo "Create sketch"
(
echo ""
x=(0)
for i in `ls -v ${files[@]}`; do convert $i -depth 16 $imagedir/$((x++))_$name.miff; done
x=(0)
for i in `ls -v $imagedir/*.miff`
do
convert $i \( -clone 0 -modulate 100,0,100 \) \( -clone 1 -negate -blur 0x4 \) \( -clone 1 -clone 2 -compose color_dodge -composite -level 0x100% \) \( -clone 3 -alpha set -channel a -evaluate set 100% +channel \) \( -clone 3 -clone 4 -compose multiply -composite \) \( -clone 0 -modulate 100,0,100 \) -delete 0-4 -compose screen -composite $sketchdir/$((x++))_$name.jpg
done
) |
yadProgress
yadError
fi
# continue or terminate
if [ "$sket" != "TRUE" ]; then
echo " " >/dev/null 2>&1; else
text=$(echo "Cleaning up - removing temporary files and folders")
echo "Cleaning up - removing temporary files and folders"
(
echo ""
) |
yad --progress --center \
--title="$title - $name" \
--progress-text="$text" \
--window-icon=$wicon \
--width=300 \
--pulsate \
--no-buttons \
--timeout=1 2>/dev/null
cleanUp
killAll
if [ -e $MYPATH/asterism ]; then
bash -x ./asterism
fi
exit
fi
# GENERATE DEFECT MAP
if [[ "$defect" != "TRUE" || "$color" = "TRUE" ]]; then
echo " " >/dev/null 2>&1; else
IFS=$'\n'
files=($(yad --file-selection --center --window-icon=$wicon --height=600 --width=480 --title="$title - Defect map - dark frames $name" --text="Select dark frames" --button=Skip:1 --button=Select:0 --multiple --separator=$'\n' 2>/dev/null))
echo "${files[@]}" 2>/dev/null
imagedir=`echo "$files" |xargs dirname`
echo $imagedir
if [ -e "$directory/project_details_$name" ]; then
echo " " >/dev/null 2>&1; else
awk 'BEGIN { FS = ":" } ; { print $0 }' $project_log | tee -a $directory/project_details_$name
fi
export MAGICK_TEMPORARY_PATH="$imagedir/.magick"
createDirIfNeeded $MAGICK_TEMPORARY_PATH
logname=$directory/log_$name 2>/dev/null
cp $log $logname 2>/dev/null
masterdir=$directory/master
tmpdir=$imagedir/.tmp