gradientmergemosaic · 2 / wer bin ich? 52 jahre pixinsight seit 2007 astronomie seit 2005 software...
TRANSCRIPT
GradientMergeMosaic
Georg Viehöver
28.4.2017
PixInsight Österreich VII
2 /
Wer bin ich?
●52 Jahre
●PixInsight seit 2007
●Astronomie seit 2005
●Software Entwickler
–C++, HPC
●Please tell me if I switch
to English...
3 /
Who am I?
●52 years old
●PixInsight since 2007
●Astronomy since 2005
●Software Developer
–C++, HPC
4 /
„Low-Tech“ Astronomie
Zentrieren den Polsuchers, Lagunennebel, Pluto
5 /
„Low-Tech“ Astronomy
Centering the Polar Finder, Laguna nebula, Pluto
6 /
Agenda
●Gradient Merge Mosaic
–Grundlagen
–Ein paar Experimente
●(Mittagspause)
●Praxis
–Umgehen mit Artefakten
●GradientHDRComposition/Compression
7 /
Agenda
●Gradient Merge Mosaic
–Foundations
–Some experiments
●(lunch break)
●Hands-on
–Managing Artifacts
●GradientHDRComposition/Compression
8 /
Die Theorie
….ist nicht so schwer
9 /
The Theory
….is not that difficult
10 /
Bilder Zusammenfügen
11 /
Merging Pictures
12 /
GradientMergeMosaic
●Astrophotos sind leichter
–Keine Perspektive
–Keine Vordergrundobjekte
–Keine Bewegung
●Astrophotos sind schwieriger
–Punktförmige Lichtquellen
–>=14 bit Kontrast
–Bewahren von Signalen <=1 bit
–Rauschen
–Projektionen
13 /
GradientMergeMosaic
●Astrophotos are easy:
–No perspective
–No foreground
–No movement
●Astrophotos are difficult:
–Point light sources
–>=14 bit contrast
–Preserve low signals<=1 bit
–Noise
–Projections
14 /
Beispiele für GMM
●Links: M31, heutiges Beispiel
●Rechts: Rogelio Bernal Andreo
http://deepskycolors.com/deepspace.html,
http://www.deepskycolors.com/archivo/2011/10/29/the-
making-of-Clouds-of-Perseus--Part-.html
15 /
Examples of GMM
●Left: M31, today‘s hands-on example
●Right: Rogelio Bernal Andreo
http://deepskycolors.com/deepspace.html,
http://www.deepskycolors.com/archivo/2011/10/29/the-
making-of-Clouds-of-Perseus--Part-.html
16 /
Nähte sind immer da
●Unvollkommene
Kalibrierung
●Wolken
●Mond
●Beleuchtung
●Temperatur
●…
●Das Auge sieht besonders
Helligkeitsübergänge
17 /
Seams are always there
●Imperfect calibrations
●Clouds
●Moon
●Artifical light
●Temperature
●…
●The eye is sensitive to
brightness changes
18 /
Arbeite mit Gradienten
●Idee: Betrachte die Helligkeitsänderungen
●Füge diese „Gradienten“ zusammen
●Rekonstruiere das Bild
●https://en.wikipedia.org/wiki/Gradient-domain_image_processing, CC BY-SA 4.0
19 /
Work on Gradients
●Idea: consider only changes in brightness
●Assemble those „Gradienten“ into one picture
●Reconstruct picture from gradients
●https://en.wikipedia.org/wiki/Gradient-domain_image_processing, CC BY-SA 4.0
20 /
Gradientenbild+Lösung
21 /
Gradients and Reconstruction
22 /
Die Theorie in 1D
●Eine Funktion f(x)=3-2x-x2+0.5*x3
●Die Ableitung zeigt wie „steil“ es auf
und abwärts geht
●Bei den Minimal- und Maximalwerten
ist die Ableitung =0
●Aus der Ableitung kann ich die
Orginalfunktion bestimmen
–„Integral“
–Bis auf konstanten Offset
–hier: 3
23 /
The Theory in 1D
●Function f(x)=3-2x-x2+0.5*x3
●The Gradient=Derivative=Slope
shows the slope of the graph
●At extrema, slope is =0
●Can reconstruct original function from
gradients
–Also called „integration“
–Same as original except for offset
–Offset here: 3
24 /
Noch eine Funktion
●Eine Funktion f(x)=sin(x2)
●Die Ableitung zeigt wie „steil“ es auf
und abwärts geht
●Bei den Minimal- und Maximalwerten
ist die Ableitung =0
●Aus der Ableitung kann ich die
Orginalfunktion bestimmen
–Integral
–Bis auf konstanten Offset
–Hier: -0.5
25 /
Another Function
●Chirp function f(x)=sin(x2)
●Again, derivative shows directions
and degree of slope
●Again, at extrema slope=0
●Reconstruct original function from
slopes
–Integration
–Except for constant offset
–Offset here: -0.5
26 /
Durchschnittsfunktion●Durchschnittliche Funktion
aus Ableitung
●Einfach Ableitungen
addieren
●Rekonstruktion über
Integrieren
27 /
Build „Average“ Function●„Average“ Function from
slopes
●Simply add derivatives
●Reconstruct via joined
integral
28 /
Überblenden von Funktionen●Polynomial und Chirp-Funtion
werden bei x=2 verbunden
●Ableitung bei x=2 hart
umschalten
●Rekonstruierte Funktion hat
keinen plötzlichen
Helligkeitsprung!
29 /
Blending of funtions●Polynomial and Chirp are
merged at x=2
●Switch derivative at x=2
●Reconstructed function has no
sudden „brightness“ jump!
30 /
●Funktioniert in 2D genauso
●Bilder sind 2D Funktionen z=f(x,y)
●Überblenden der Ableitungen da wo
–Helligkeitswert im anderen Bild=0,
–Ein Bild über dem anderen liegt (overlay), oder
–Durchschnitt der Ableitungen (average), und/oder
–Langsamer Übergang (abwedeln, „feathern“)
31 /
●Works just like that also in 2D
●Images are 2D functions z=f(x,y)
●Blend derivates where
–Brightness in one image =0,
–Where one image lies on top of the other (overlay), or
–Compute average derivative(average), and/or
–If necessary, blend derivatives smoothly(„feathern“)
●Gradienten sind die Differenzen zwischen Pixeln:
●Gradientenbild:
●Kann Bild wiederherstellen, bis auf ersten Wert:
●Das ist die konstante Differenz in den Integralen
●Möglich mit beliebigen Delta-Werten
32 /
Perfekte 1D Lösung
Wert Delta Wert Delta Wert
1 2 3 -5 -2
Wert Delta Wert Delta Wert
0 2 2 -5 -3
Wert Delta Wert Delta Wert
? 2 ? -5 -?
●Gradients are the differences between pixels:
●Gradient image:
●Reconstruct image except for first value:
●We also have the constant offset as seen with integration
●Exact solution for any combination of Delta-Values
33 /
Perfect 1D Solutions
Value Delta Value Delta Value
1 2 3 -5 -2
Value Delta Value Delta Value
0 2 2 -5 -3
Value Delta Value Delta Value
? 2 ? -5 -?
34 /
Widersprüchliche 2D Solutions
●Gradientenbild:
●Lösung mit 0 oben links: Ausgleich:
●Seifenblaseneffekt. Ähnliche Formeln!
Wert DeltaX Wert
Wert 0 2 2
DeltaY 4 --- 0
Wert 4 -1 3 o. 2
Wert DeltaX Wert
Wert ? 2 ?
DeltaY 4 --- 0
Wert ? -1 ?
Wert DeltaX Wert
Wert 0 2 2
DeltaY 4 --- 0
Wert 4 -1 2.5
35 /
Imperfect 2D Solutions
●Gradient image:
●Solution with 0 as top left value Regression:
●Soap bubble effect. Actually, the mathematics are similar
Value DeltaX Value
Value 0 2 2
DeltaY 4 --- 0
Value 4 -1 3 o. 2
Value DeltaX Value
Value ? 2 ?
DeltaY 4 --- 0
Value ? -1 ?
Value DeltaX Value
Value 0 2 2
DeltaY 4 --- 0
Value 4 -1 2.5
36 /
Rechentechnik
●Bilder sind Funktionen mit x*y~10 Mio. Stützstellen
●Gradienten werden numerisch durch Differenzen zu
Nachbarpixeln gebildet
●Integral=Lösung einer Poisson-Gleichung
●Diskrete Cosinus Transformation (DCT)
●Es gibt mitunter keine perfekte Lösung => Ausgleich
●Details:
http://www.amitkagrawal.com/ICCV2007Course/ ,
Download the slides
37 /
Computation
●Images are functions with x*y~10 Mio. supporting
points
●Gradients are the differences to neighboring pixels
●Integral=Solution of „Poisson equation“
●Discrete Cosinus Transform (DCT)
●Sometimes no perfect solution=>regression
●Details:
http://www.amitkagrawal.com/ICCV2007Course/ ,
Download the slides
38 /
GradientMergeMosaic GUI
●Target Frames:
–Registrierte Teilbilder
–Reihenfolge nur bei „Type Of Combination“=Overlay wichtig. Spätere Bilder „gewinnen“
●Type of Combination
●Shrink Radius: Anzahl Pixel die am
Rand der Teilbilder weggenommen
werden (Aliasing)
●Feather Radius: Übergangsgröße, hilft
manchmal bei Artefakten
●Blackpoint: Pixel <=Wert sind
„durchsichtig“
●Generate Mask: Diagnostic
Hat Dokumentation !
39 /
GradientMergeMosaic GUI
●Target Frames:
–Registered mosaic frames
–Order only important for „Type Of Combination=Overlay“. Later images overlay others
●Type of Combination
●Shrink Radius: Number of pixels
removed from border (Aliasing)
●Feather Radius: Featering between
images, sometimes helps with artifacts
●Blackpoint: Pixel <=blackpoint are
considered „transparent“
●Generate Mask: Diagnostic
Has Documentation !
40 /
Ein paar Experimente
●X/Y-Bilder erzeugt mit
Pixelmath
„iif(X()>0.5,0.0,Y())“+Rot
ation
–...\Data\
Experiments
●Wichtig:
–Shrink radius=0
–Feather radius=0
41 /
Some Experiments
●X/Y-Images produced
with Pixelmath
„iif(X()>0.5,0.0,Y())“+Rot
ation
–...\Data\
Experiments
●Important:
–Shrink radius=0
–Feather radius=0
42 /
Versuche mit Sibylle
●Auffüllen des
Schwarzen
Quadrants
●Beachte Wirkung
von Reihenfolge
bei Overlay
43 /
Experiments with Sibylle
●Filling of black
quadrant
●Watch influence of
order in Overlay
mode
44 /
Shrinken
●Entfernen von
Aliasing-
Treppenstufen
●Entstehen bei
Rotation,
StarAlignment
und anderen
Operationen
●Wird durch
Erosion entfernt
45 /
Shrinken
●Removes
Aliasing-Pixels
●Created during
StarAlignment,
Rotation and
other operations
●Removed via
Erosion(=shrink)
46 /
Was noch fehlt
●Das Ergebnis von GMM ist (mehr oder weniger) linear
●Arbeitet „Additiv“, passt also keine Kontraste an
●Bei Farbbildern: Jeder Kanal wird einzeln behandelt
●Es gibt Probleme mit Artefakten an Kachelrändern
●Kann nicht ausgleichen:
–Skalenunterschiede (Kontraste)
–Texturen (Rauschen, Fixed Pattern Noise, … )→vorher z.B. CanonBandingReduction
47 /
Final Remarks
●GMM result is (more or less) linear
●Works „Additiv“, i.e. does not match contrasts
●For color images: Every channel is handelt separately by
GMM
●We have an artifact issue at mosaic tile borders
●GMM cannot help with:
–Scale differences (contrast)
–Textures (Noise, Fixed Pattern Noise,...)->Preprocessing (CanonBandingReduction, ABE, ..)
48 /
Die Praxis
Beispieldaten und Arbeitschritte
49 /
Hands-On
Example Data and Processing Steps
50 /
Die Daten●Bob‘s (KuriousGeorge) Andromeda
Mosaik
–...\Data\Andromeda
●Kalibrierte Luminanz-TIFFs
●Dateien „Andromeda Galaxy 2-X“
●Im Workshop beschränkt Euch auf
zentrale 6 Bilder:
–Speicherplatz, Rechenzeit
–Arbeitszeit
–...\Data\Andromeda_SubSet
26 27 28 29 30
21 22 23 24 25
16 17 18 19 20
11 12 13 14 15
6 7 8 9 10
1 2 3 4 5
51 /
The Data●Bob‘s (KuriousGeorge) Andromeda
Mosaic
–...\Data\Andromeda
●Calibrated Luminance-TIFFs
●Files „Andromeda Galaxy 2-X“
●Workshop: Limited to 6 central
images:
–RAM, Computing Time
–Manual work time
–...\Data\Andromeda_SubSet
26 27 28 29 30
21 22 23 24 25
16 17 18 19 20
11 12 13 14 15
6 7 8 9 10
1 2 3 4 5
52 /
Überblick1)Bilder nach Float wandeln
2)Basis-Mosaik für Alignment bauen (StarAlignment
Register Union)
3)Registrieren auf Basis Mosaik (StarAlignment Match
Images)
4)Optional: Maske zur Orientierung (ImageIntegration
Rejection Low)
5)GradientMergeMosaic (endlich!)
6)Artefakte bekämpfen (CloneStamp), zeitaufwendig
7)Weiter mit 5) (typischerweise 4-8 mal)
8)(Normale Bearbeitung eines Lineare Bildes)
53 /
Overview1)Translate images to float32
2)Build Base Mosaic (StarAlignment Register Union)
3)Register to Base Mosaic (StarAlignment Match Images)
4)Optional: Mask for orientation (ImageIntegration
Rejection Low)
5)GradientMergeMosaic (finally!)
6)Artefakte bekämpfen (CloneStamp), time consuming
7)Continue with 5) (typical 4-8 times)
8)(Usual processing of linear image)
54 /
Bilder nach Float wandeln
●Scripts/Batch Processing/Batch Format Conversion
55 /
Translate Images to Float
●Scripts/Batch Processing/Batch Format Conversion
56 /
Basis-Mosaik 1●Empfohlene Einstellungen:
–Projective Transformation oder 2D Surface Splines
–Distortion Correction
–Register/Union-Mosaic
–Frame Adaption
●Jeweils ein neues Bild
hinzufügen:
–Vorheriges als Referenz
–Neues hinzufügen mit Drag+Drop Triangle
57 /
Base-Mosaic 1●Recommended:
–Projective Transformation or 2D Surface Splines
–Distortion Correction
–Register/Union-Mosaic
–Frame Adaption
●Jeweils ein neues Bild
hinzufügen:
–Vorheriges als Referenz
–Add new with Drag+DropTriangle/Local apply
58 /
Basis-Mosaik 2
●Erster Schritt: Bild 13+18
●Danach jeweils ein Bild zu
entstandenem Mosaik
hinzufügen
●Bei Problemen:
–Nachhelfen mit Previews
59 /
Base-Mosaic 2
●First Step: tile 13+18
●Then stepwise add another
image to just created
mosaic
●Problems: Help with
Previews
60 /
Basis-Mosaik 3
●Mit weiteren Bildern fortsetzen
●Bevorzuge Spiralmuster
–Hoffnung auf minimierte Verzerrungen
●Bei Problemen:
–Einfach mit nächstem weitermachen
–Schwierige Bilder später nochmal probieren
–Nachhelfen mit Previews
–(hier: 7,10,26,21,1,5)
●(Zentrale 6 reichen für Demo)
26 27 28 29 30
21 22 23 24 25
16 17 18 19 20
11 12 13 14 15
6 7 8 9 10
1 2 3 4 5
61 /
Base-Mosaic 3
●Continue with other images
●I prefer spiral pattern
–Hoping for reduced distortions
●On problems:
–Continue with next and try again later, or
–Help with Previews
●(Zentral 6 images are enough for workshop)
26 27 28 29 30
21 22 23 24 25
16 17 18 19 20
11 12 13 14 15
6 7 8 9 10
1 2 3 4 5
62 /
Basis-Mosaik Resultat
●Hat Schwächen
●Eignet sich
aber die zu
mergenden
Bilder
auszurichten
63 /
Base-Mosaic Result
●Visible seams
●Suitable to
create tiles for
GMM
64 /
Registrieren auf Basis-Mosaik
●Empfohlene Einstellungen:
–Distortion Correction
–Register/Match Images
–(Descriptor Type: Triangle Similarity)
–Compute Intersections: Always
–Global apply
●Notfalls für einzelne Bilder mit
Preview nachhelfen
●(hier: 5, 21)
65 /
Register to Base Mosaic
●Recommended Settings:
–Distortion Correction
–Register/Match Images
–(Descriptor Type: Triangle Similarity)
–Compute Intersections: Always
–Global Apply
●If necessary: Help with
Previews
●(hier: 5, 21)
66 /
Registrierte Bilder
●Resultat ist Satz
von registrierten
Bildern
●Hintergrund
jeweils schwarz
67 /
Registered Tiles
●Result is set of
files with registered
tiles
●Black=Transparent
Background
68 /
Optional: Maske zur Orientierung
●Per normaler
ImageIntegration
●Rejection Low
●Später per
Drag&Drop auf GMM
Resultat als Maske
nutzen
●Hilft bei Orientierung
69 /
Optional: Mask for Orientation
●Per standard
ImageIntegration
●Rejection Low
Image
●Later set as mask
via Drag&Drop on
GMM Resultat
●Helps identify
source of artifacts
70 /
GradientMergeMosaic
●Braucht viel
Speicher (10GB für
das vollständige
Bild)
●Sieht schon
ziemlich gut aus
●Abgesehen von
Artefakten
71 /
GradientMergeMosaic
●Needs lots of RAM
(>10GB for complete
Mosaic)
●Looking pretty good
●Except for artifacts
72 /
Artefakte 1
●Liegen bei hellen
Sternen auf den
Kachelrändern
●Einige
verschwinden
durch „Feathern“,
aber nicht alle
73 /
Artefacts 1
●Located at borders
of tiles
●Some go away
with „feather“, but
not all
74 /
Artefakts 2●Entstehen bei hellen Sternen an
Kachelrand
●Seifenblasen Effekt
–Deutlich unterschiedliche Helligkeiten des gleichen Sterns in 2 Bildern (trotz Frame Adaption)
–Alignment-Probleme (auch <1 Pixel!)
●Workarounds:
–Feathern (tut‘s manchmal)
–Nicht-Lineare Bilder (nicht empfohlen)
–Ausstempeln
75 /
Artefacts 2●Located at bright stars at tile borders.
●Soap Bubble Effect
–Different brightness of same star in 2 images (despite Frame Adaption)
–Alignment-Problems (even <1 Pixel!)
●Workarounds:
–Feathern (sometimes helps)
–Non-lineart images (non-recommended)
–Remove one star image via CloneStamo
76 /
Randsterne entfernen
●Für alle Artefakte:
●Kritische
Randsterne
reichlich
wegnehmen
●CloneStamp
● Radius<=5
● Softness=0.0
● Opacity=1.0
●Und wieder GMM
●Wiederholen wie
notwendig !
77 /
Remove Border Stars
●For all Artefacts:
●Remove critical star
●CloneStamp
● Radius<=5
● Softness=0.0
● Opacity=1.0
●Store patched
image
●Repeat GMM
●Repeat as often as
necesarry !
78 /
GMM Ergebnis
79 /
GMM Result
80 /
Was bleibt?●Artefakte am Rand: Wegschneiden
●Textur-Unterschiede (Rauschen, Fixed
Pattern Noise): Kriegt man nicht weg
●Alignment-Fehler: Nochmal von Vorne
für diese Kachel
–DynamicAlignment
–StarAlignment mit 2D-Surface Splines
–MosaicByCoordinates
●DynamicBackgroundExtraction
●Dann weiter wie mit üblichen linearen
Bildern
81 /
What else?●Other border artifacts: Cut away
●Textur-Differences (Noise, Fixed Pattern
Noise): GMM cannot help. Maybe add
noise?
●Alignment-Errors: Try again for this tile
–DynamicAlignment
–StarAlignment mit 2D-Surface Splines
–MosaicByCoordinates
●DynamicBackgroundExtraction
●Continue as with usual Linear images
Registration und Frame Adaption
- Viele Alternativen
- Im Workshop: Alles selbst-referentiell, keine
äußeren Daten
- Viele Alternativen mit externen Daten
- Alignment zu „gemaltem“ Bild, z.B. CatalogStarGenerator, StarGenerator, Stellarium, ...- Plate solve to this data(ImageSolver, Blind Solver,
ManualImageSolver)
- MosaicByCoordinates (especially for wide fields)
- Frame Adaption- AperturePhotometry, Fluxx, G2V
- ...
Registration and Frame Adaption
- Many alternatives
- In Hands-on: All data was self registered, no foreign
data
- Many alternatives with help of other data
- Align to rendered image, for instance with CatalogStarGenerator, StarGenerator, Stellarium, ...- Solve via plate solver (ImageSolver, Blind Solver,
ManualImageSolver)
- MosaicByCoordinates (especially for wide fields)
- Frame Adaption- AperturePhotometry, Fluxx, G2V
- ...
84 /
Und noch 2 Werkzeuge
Verwandte von GMM:
GradientHDRCompression
GradientHDRComposition
85 /
Two more Tools
Relatives of Gradient Merge Mosaic:
GradientHDRCompression
GradientHDRComposition
86 /
GradientHDRCompression
●Feine Details
hervorheben
●Arbeitet mit
Abschneiden starker
Gradienten
–Max log10(Gradient)
–Feinstruktur bleibt übrig
●Artefakte?
87 /
GradientHDRCompression
●Enhance fine detail
●Reduces strong
contrasts
–Max log10(Gradient)
–Delicate strukture remains
●Unclear if supported
by data
88 /
GradientHDRComposition
●Ähnlich HDRComposition
●Aber ganz anderes
Verfahren
–Nutze die stärksten Gradienten
–Idee: Über- oder unterbelichtete Regionen sind Gradienten-„flach“
89 /
GradientHDRComposition
●Similar to HDRComposition
●Entirely different approach
–Use the strongest graident
–In over- or under-exposed regions gradients are „flat“
90 /
Zusammenfassung
●GMM ermöglicht nahtlose Mosaike
–Aufwändig: Artefakte bekämpfen
–Kenne den Algorithmus, dann kennst Du auch die Gegenmaßnahmen
–Super Ergebnisse!
●GradientHDRComposition und
GradientHDRCompression lohnen einen Blick
●Viel Spaß!
91 /
Conclusion
●GMM enables seamless mosaics
–Fighting artifacts is work intensive
–Know the algorithm, then fight artefacts
–Can produce great results!
●GradientHDRComposition and
GradientHDRCompression may be useful
●Enjoy!
92 /
Backup
●Anybody here who wants to write anti-artifact script?
●Idea:
● Identify stars with StarMask
● Identify tile area with Binarize
● Shrink area with MorphologicalTransform/Erosion and Radius<0.5*tile overlap
● Combine shrinked area, original area, star mask into mask limited to border regions with PixelMath
● Resulting Mask stamps out stars at border in tile
● Apply to many tiles with ImageContainer
Handout
26 27 28 29 30
21 22 23 24 25
16 17 18 19 20
11 12 13 14 15
6 7 8 9 10
1 2 3 4 5
Handout 2
Frame Adaption
Projective or
Spline
Distortion
Correction
Base Mosaic:
Union-Mosaic,
local apply
Final Mosaic:
Match Images,
global apply