fits

package
v0.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2023 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const HeaderLineSize int = 80 // Line size of a FITS header

Variables

This section is empty.

Functions

func EqualInt32Slice

func EqualInt32Slice(a, b []int32) bool

Equal tells whether a and b contain the same elements. A nil argument is equivalent to an empty slice.

func HSLuvToLinearRGB

func HSLuvToLinearRGB(h, s, l float32) (r, g, b float32)

convert HSLuv to linear RGB; faster; with color-preserving clamping

Types

type Header struct {
	Bools    map[string]bool
	Ints     map[string]int32
	Floats   map[string]float32
	Strings  map[string]string
	Dates    map[string]string
	Comments []string
	History  []string
	End      bool
	Length   int32
}

FITS header data

func NewHeader

func NewHeader() Header

Creates a FITS header initialized with empty maps and arrays

func (*Header) Print

func (h *Header) Print()

func (*Header) Write

func (h *Header) Write(w io.Writer)

Write additional header key/value pairs, if any

type Image

type Image struct {
	ID       int    // Sequential ID number, for log output. Counted upwards from 0 for light frames. By convention, dark is -1 and flat is -2
	FileName string // Original file name, if any, for log output.

	Header Header  // The header with all keys, values, comments, history entries etc.
	Bitpix int32   // Bits per pixel value from the header. Positive values are integral, negative floating.
	Bzero  float32 // Zero offset. True pixel value is Bzero + Bscale * Data[i].
	Bscale float32 // Value scaler. True pixel value is Bzero + Bscale * Data[i].
	// Helps implement unsigned values with signed data types.
	Naxisn []int32 // Axis dimensions. Most quickly varying dimension first (i.e. X,Y)
	Pixels int32   // Number of pixels in the image. Product of Naxisn[]

	Data []float32 // The image data

	Exposure float32 // Image exposure in seconds

	Stats           *stats.Stats // Basic image statistics: min, mean, max
	MedianDiffStats *stats.Stats // Local median difference stats, for bad pixel detection, star detection

	Stars []star.Star // Star detections
	HFR   float32     // Half-flux radius of the star detections

	Trans    star.Transform2D // Transformation to reference frame
	Residual float32          // Residual error from the above transformation
}

A FITS image. Spec here: https://fits.gsfc.nasa.gov/standard40/fits_standard40aa-le.pdf Primer here: https://fits.gsfc.nasa.gov/fits_primer.html

func NewImage

func NewImage() *Image

Creates a FITS image initialized with empty header

func NewImageBinNxN

func NewImageBinNxN(src *Image, n int32) *Image

Apply NxN binning to source image and return new resulting image

func NewImageFromFile

func NewImageFromFile(fileName string, id int, logWriter io.Writer) (i *Image, err error)

func NewImageFromImage

func NewImageFromImage(img *Image) *Image

Creates a FITS image from given image. New data array will be allocated

func NewImageFromNaxisn

func NewImageFromNaxisn(naxisn []int32, data []float32) *Image

Creates a FITS image from given naxisn. Data is not copied, allocated if nil. naxisn is deep copied

func NewImageFromStars

func NewImageFromStars(src *Image, hfrMultiple float32) *Image

Show stars detected on the source image as circles in a new resulting image

func NewImageMasterDataFromFile

func NewImageMasterDataFromFile(fileName string, id int, logWriter io.Writer) (i *Image, err error)

func NewRGBFromChannels

func NewRGBFromChannels(chans []*Image, ref *Image, logWriter io.Writer) *Image

Combine single color images into one multi-channel image. All images must have the same dimensions, or undefined results occur.

func (*Image) AdjustChroma

func (f *Image) AdjustChroma(gamma, threshold float32)

Apply given gamma correction to color saturation (CIE HCL chroma), for luminances above the given threshold. Data must be normalized to [0,1]. Operates in-place.

func (*Image) AdjustChromaForHues

func (f *Image) AdjustChromaForHues(from, to, factor float32)

Selectively adjusts CIE HCL chroma for hues in given range by multiplying with given factor. Data must be HCL. Useful for desaturating purple stars

func (*Image) ApplyGamma

func (f *Image) ApplyGamma(g float32)

Apply gamma correction to image. Image must be normalized to [0,1] before. Operates in-place.

func (*Image) ApplyGammaToChannel

func (f *Image) ApplyGammaToChannel(chanID int, g float32)

Apply gamma correction to image. Image must be normalized to [0,1] before. Operates in-place.

func (*Image) ApplyLuminanceToCIExyY

func (hsl *Image) ApplyLuminanceToCIExyY(lum *Image)

Applies luminance to existing 3-channel image with luminance in 3rd channel, all channels in [0,1]. All images must have the same dimensions, or undefined results occur.

func (*Image) ApplyMidtones

func (f *Image) ApplyMidtones(mid, black float32)

Apply midtones correction to given image. Data must be normalized to [0,1]. Operates in-place.

func (*Image) ApplyMidtonesToChannel

func (f *Image) ApplyMidtonesToChannel(chanID int, mid, black float32)

Apply midtones correction to given channel of given image. Data must be normalized to [0,1]. Operates in-place.

func (*Image) ApplyPartialGamma

func (f *Image) ApplyPartialGamma(from, to, g float32)

Apply gamma correction to image in given range. Image must be normalized to [0,1] before. Operates in-place.

func (*Image) ApplyPartialGammaToChannel

func (f *Image) ApplyPartialGammaToChannel(chanID int, from, to, g float32)

Apply gamma correction to given channel of the image. Image must be normalized to [0,1] before. Operates in-place.

func (*Image) ApplyPixelFunction

func (f *Image) ApplyPixelFunction(pf PixelFunction, args interface{})

Apply given pixel function to the image. Uses thead parallelism across all available CPUs. Operates in-place.

func (*Image) ApplyPixelFunction1Chan

func (f *Image) ApplyPixelFunction1Chan(chanID int, pf PixelFunction, args interface{})

Apply given pixel function to given channel of the image. Uses thead parallelism across all available CPUs. Operates in-place.

func (*Image) ApplyPixelFunction3Chan

func (f *Image) ApplyPixelFunction3Chan(pf PixelFunction3Chan, args interface{})

Apply given pixel function to all channels of the image. Uses thead parallelism across all available CPUs. Data must be normalized to [0,1]. Operates in-place.

func (*Image) ApplyScaleOffset

func (f *Image) ApplyScaleOffset(scale, offset float32)

Applies given scale factor and offset to image. Operates in-place.

func (*Image) ApplyScaleOffsetToChannel

func (f *Image) ApplyScaleOffsetToChannel(chanID int, scale, offset float32)

Applies given scale factor and offset to image. Operates in-place.

func (*Image) CIEHSLToRGB

func (f *Image) CIEHSLToRGB()

Convert CIE HSL to RGB pixels. Operates in-place. https://en.wikipedia.org/wiki/Colorfulness#Saturation

func (*Image) DimensionsToString

func (f *Image) DimensionsToString() string

func (*Image) FillCircle

func (f *Image) FillCircle(xc, yc, r, color float32)

Fill a circle of given radius on the FITS image

func (*Image) HSLuvToRGB

func (f *Image) HSLuvToRGB()

Convert HSLuv to RGB pixels. Operates in-place. https://www.hsluv.org/

func (*Image) MatchHistogram

func (f *Image) MatchHistogram(refStats *stats.Stats)

Adjust image data to match the histogram shape of refStats. Assumes f.Stats are current; and updates them afterwards.

func (*Image) MatchLocation

func (f *Image) MatchLocation(refLocation float32)

Adjust image data to match the histogram peak of refStats. Assumes f.Stats are current; and updates them afterwards.

func (*Image) MonoToHSLLum

func (f *Image) MonoToHSLLum()

Converts a monochromic image to HSL Luminance. Data must be normalized to [0,1]. Operates in-place.

func (*Image) MonoToHSLuvLum

func (f *Image) MonoToHSLuvLum()

Converts a monochromic image to HSLuv Luminance. Data must be normalized to [0,1]. Operates in-place.

func (*Image) NeutralizeBackground

func (f *Image) NeutralizeBackground(low, high float32)

Adjust CIE HCL chroma by multiplying with 0 for values below low, with 1 above high, and interpolating linearly in between. Data must be HCL. Operates in-place.

func (*Image) Normalize

func (f *Image) Normalize()

Normalize image to [0..1] based on basic stats. Operates in-place.

func (*Image) OffsetRGB

func (f *Image) OffsetRGB(r, g, b float32)

Offsets each color channel by a factor, clamping to Operates in-place on image data normalized to [0,1].

func (*Image) PopHeaderInt32

func (fits *Image) PopHeaderInt32(key string) (res int32, err error)

func (*Image) PopHeaderInt32OrFloat

func (fits *Image) PopHeaderInt32OrFloat(key string) (res float32, err error)

func (*Image) Project

func (img *Image) Project(destNaxisn []int32, trans star.Transform2D, outOfBounds float32) (res *Image, err error)

Projects an image into a new coordinate system with the given transformation. Fills in missing pixels with the given out of bounds value. Uses bilinear interpolation for now.

func (*Image) RGBToCIEHSL

func (f *Image) RGBToCIEHSL()

Convert RGB to CIE HSL pixels. Operates in-place. https://en.wikipedia.org/wiki/Colorfulness#Saturation

func (*Image) RGBToHCL

func (f *Image) RGBToHCL()

Convert RGB to CIE HCL pixels. Operates in-place.

func (*Image) RGBToHSLuv

func (f *Image) RGBToHSLuv()

Convert RGB to HSLuv pixels. Operates in-place. https://www.hsluv.org/

func (*Image) Read

func (fits *Image) Read(f io.Reader, readData bool, logWriter io.Writer) (err error)

func (*Image) ReadFile

func (fits *Image) ReadFile(fileName string, readData bool, logWriter io.Writer) error

Read FITS data from the file with the given name. Decompresses gzip if .gz or gzip suffix is present. Reads metadata only (fast) if readData is false.

func (*Image) RotateColors

func (f *Image) RotateColors(from, to, offset, lthres float32)

Selectively rotate hues in a given range. Data must be HSLuv. Useful to create Hubble palette images from narrowband data, by turning greens to yellows, before applying SCNR

func (*Image) SCNR

func (f *Image) SCNR(factor float32)

Apply subtractive chroma noise reduction to the green channel. Data must be normalized to [0,1]. Uses average neutral masking method with luminance protection. Typically used to reduce green cast in narrowband immages when creating Hubble palette images

func (*Image) ScaleOffsetClampRGB

func (f *Image) ScaleOffsetClampRGB(alphaR, betaR, alphaG, betaG, alphaB, betaB float32)

Linearly transforms each color channel with multiplier alpha and offset beta, then clamps result to [0,1]

func (*Image) ScaleRGB

func (f *Image) ScaleRGB(r, g, b float32)

Scales each color channel by a factor, clamping to Operates in-place on image data normalized to [0,1].

func (*Image) SetBlackWhite

func (f *Image) SetBlackWhite(blackPerc, whitePerc float32, logWriter io.Writer)

Sets black point and white point of the image to clip the given percentage of pixels.

func (*Image) SetBlackWhitePoints

func (f *Image) SetBlackWhitePoints(block int32, border, skipBright, skipDim float32, shadows, highlights RGB, logWriter io.Writer) error

Set image black point iteratively. First match histogram scale and location among the channels. Then find the darkest block, and set it to the desired color; and find the average star color, and set it to the desired color

func (*Image) ShiftBlackToMove

func (f *Image) ShiftBlackToMove(before, after float32)

Shift black point so a defined before value becomes the given after value. Operates in-place on image data normalized to [0,1].

func (*Image) ShiftBlackToMoveChannel

func (f *Image) ShiftBlackToMoveChannel(chanID int, before, after float32)

Shift black point so a defined before value becomes the given after value. Operates in-place on image data normalized to [0,1].

func (*Image) ToXyy

func (f *Image) ToXyy()

Convert RGB to xyY pixels. Operates in-place.

func (*Image) Write

func (fits *Image) Write(f io.Writer) error

Writes an in-memory FITS image to an io.Writer.

func (*Image) WriteFile

func (fits *Image) WriteFile(fileName string) error

Writes an in-memory FITS image to a file with given filename. Creates/overwrites the file if necessary. Compresses with gzip if .gz or gzip suffix is present.

func (*Image) WriteJPG

func (f *Image) WriteJPG(writer io.Writer, quality int) error

Write a FITS image to JPG. Image must be normalized to [0,1]

func (*Image) WriteJPGToFile

func (f *Image) WriteJPGToFile(fileName string, quality int) error

Write a FITS image to JPG. Image must be normalized to [0,1]

func (*Image) WriteMonoJPG

func (f *Image) WriteMonoJPG(writer io.Writer, quality int) error

Write a grayscale FITS image to JPG. Image must be normalized to [0,1]

func (*Image) WriteMonoJPGToFile

func (f *Image) WriteMonoJPGToFile(fileName string, quality int) error

Write a grayscale FITS image to JPG. Image must be normalized to [0,1]

func (*Image) XyyToRGB

func (f *Image) XyyToRGB()

Convert Xyy to RGB pixels. Operates in-place.

type LinearsRGB

type LinearsRGB struct {
	R float32
	G float32
	B float32
}

func (LinearsRGB) ToOkHcl

func (c LinearsRGB) ToOkHcl() OkHcl

func (LinearsRGB) ToOkLab

func (c LinearsRGB) ToOkLab() OkLab

type OkHcl

type OkHcl struct {
	H float32
	C float32
	L float32
}

func (OkHcl) ToLinearsRGB

func (c OkHcl) ToLinearsRGB() LinearsRGB

func (OkHcl) ToOkLab

func (c OkHcl) ToOkLab() OkLab

type OkLab

type OkLab struct {
	L float32
	A float32
	B float32
}

func (OkLab) ToLinearsRGB

func (c OkLab) ToLinearsRGB() LinearsRGB

func (OkLab) ToOkHcl

func (c OkLab) ToOkHcl() OkHcl

type PixelFunction

type PixelFunction func(data []float32, params interface{})

A pixel function. Operates in-place. For parallelization across CPUs.

type PixelFunction3Chan

type PixelFunction3Chan func(c0, c1, c2 []float32, params interface{})

A three-channel pixel function. Data must be normalized to [0,1]. Operates in-place. For parallelization across CPUs.

type RGB

type RGB struct {
	R float32
	G float32
	B float32
}

A RGB color in float32

func (RGB) String

func (rgb RGB) String() string

Print RGB color as a human-readable string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL