profoundPixelCorrelation: Pixel to pixel correlation statistics

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/profoundPixelCorrelation.R

Description

Returns the x and y dimension pixel-to-pixel correlation (often called covariance) at various scales, optionally returning a diagnostic plot.

Usage

1
2
3
4
5
profoundPixelCorrelation(image = NULL, objects = NULL, mask = NULL, sky = 0, skyRMS = 1,
lag = c(1:9, 1:9 * 10, 1:9 * 100, 1:9 * 1000, 1:9 * 10000), fft = TRUE, plot = FALSE,
ylim=c(-1,1), log='x', grid=TRUE, ...)
profoundSkySplitFFT(image = NULL, objects = NULL, mask = NULL, sky = 0, skyRMS = 1,
skyscale = 100, profound = NULL)

Arguments

image

Numeric matrix; required, the image we want to analyse. Note, image NAs are treated as masked pixels.

objects

Boolean matrix; optional, object mask where 1 is object and 0 is sky. If provided, this matrix *must* be the same dimensions as image.

mask

Boolean matrix; optional, parts of the image to mask out (i.e. ignore), where 1 means mask out and 0 means use for analysis. If provided, this matrix *must* be the same dimensions as image.

sky

Numeric; the absolute sky level. Can be a scalar or a matrix matching the dimensions of image (allows values to vary per pixel).

skyRMS

Numeric; the RMS of the sky. Can be a scalar or a matrix matching the dimensions of image (allows values to vary per pixel).

lag

Interger verctor; the pixel lags to measure pixel-to-pixel correlation over the x and y dimensions.

fft

Logical; if TRUE the 2D FFT is computed and the modulus image matrix is returned to fft and the (image-sky)/skyRMS is return to image_sky, if FALSE the fft and image_sky objects are returned as NULL. object and mask pixels are used to identify pixels to replace as described below.

plot

Logical; should a x/y correlation diagnostic plot be generated?

ylim

Numeric vector; range of data to display (see magplot for details). Only relevant if plot=TRUE.

log

Character scalar; log axis arguments to be passed to plot. E.g. use 'x', 'y', 'xy' or 'yx' as appropriate (see magplot for details). Only relevant if plot=TRUE.

grid

Logical; indicates whether a background grid should be drawn onto the plotting area (see magplot for details). Only relevant if plot=TRUE.

skyscale

Numeric scalar; required, the pixel scale that the FFT should split the provided image_sky at. This should be chosen so as to separate out true sky modes and possible sources still in the sky. Too small and real sources will be put into the sky_lo image returned, so larger is usually safer.

profound

List; object of class 'profound'. If this is provided then missing input arguments are taking directly from this structure (see Examples). As an added convenience, you can assign the profound object directly to the image input.

...

Further arguments to passe to magplot. Only relevant if plot=TRUE.

Details

profoundPixelCorrelation:

All statistics are computed on (image-sky)/skyRMS. If fft=TRUE this matrix is return to image_sky.

The function is useful to assessing a number of image attributes. For one things it tells you whether all spatial variance has been detected and removed at small scales as objects (e.g. using profoundProFound), or at larger scales as sky fluctuations. Assuming the object detection and sky removal has worked well, the remaining pixel-to-pixel correlation likely represents instrument level covariance. In practice nearly all processes produce positive pixel correlation, but it is not impossible that negative correlation can be introduced during the reduction process, particularly when over-subtracting the sky around bright stars.

For calculating the raw pixel-to-pixel correlation (as returned by cortab) mask and object pixels are ignored, so correlation is only considered where both pixels are flagged as un-masked sky pixels. The 2D image FFT output (fft) replaces masked or object pixels with Normally distributed noise after the input image has had the sky subtracted and divided by the skyRMS. Note that this means the FFT generated is partly stochastic (it will differ a bit each time it is run), but in practice it will be quite persistant for large scales (the centre) and stochastic at small scales (around the edge of the FFT image).

The slightly weird units used for the k modes of the FFT (see the value section below) is convenient because it means we can correctly label the FFT image in integer pixels counting out from the centre. The way to interpret the k-modes is that if you have an image of size L=356x356 then you can find the pixel representing a particular scale by computing L/S, where S is the scale of interest in pixels. I.e. S=356 is the mode representing the full image length scale since L/S=1 and can be found 1 pixel from the centre, whilst S=178/89 represents the half/quarter image scale and can be found at pixels L/S=2 or 4 (respectively) from the centre. From this reasoning we have Nyqvist sampling at 356/2=178 pixels from the centre (i.e. the edges of the FFT image).

The relative standard-deviations returned in cortab are calculated by taking the standard-deviation of the lagged pixel differences of (image-sky)/skyRMS and dividing through by sqrt(2). This means for well behaved data they should be 1, and the dashed lines on the diagnostic plot should fall on 1.

profoundSkySplitFFT:

The FFT split output separates the provided image into hi k (sky_hi) and low k (sky_lo) modes. The idea is that sky_lo might represent additional sky with complex structure (not captured by the bicubic/bilinear extimated sky) that still needs to be subtracted off the image, whilst sky_hi might contain some as yet un-subtracted sources.

In principle profoundSkySplitFFT can be run with any image, but the separation into the low and high k modes is not easily interpretable in the presence of many real objects since they will dominate the power at all scales (trust me on this).

Value

profoundPixelCorrelation:

A list containing three objects:

Author(s)

Aaron Robotham

See Also

profoundProFound

Examples

 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
## Not run: 
image=readFITS(system.file("extdata", 'VIKING/mystery_VIKING_Z.fits', package="ProFound"))

profound=profoundProFound(image, skycut=1.5, magzero=30, verbose=TRUE, plot=TRUE)

corout_raw=profoundPixelCorrelation(image$imDat, plot=TRUE)
magimage(corout_raw$fft, xlab='kx (2pi/356pix)', ylab='ky (2pi/356pix)')
points(0, 0, cex=10, col='red')

# There is clearly some residual structure masking out the brighter parts of objects:

corout_objects=profoundPixelCorrelation(image$imDat, sky=profound$sky,
skyRMS=profound$skyRMS, objects=profound$objects, plot=TRUE)
magimage(corout_objects$fft, xlab='kx (2pi/356pix)', ylab='ky (2pi/356pix)')
points(0, 0, cex=10, col='red')

# Using the more aggressive objects_redo removed nearly all of this:

corout_objects_redo=profoundPixelCorrelation(image$imDat, sky=profound$sky,
skyRMS=profound$skyRMS, objects=profound$objects_redo, plot=TRUE)
magimage(corout_objects_redo$fft, xlab='kx (2pi/356pix)', ylab='ky (2pi/356pix)')
points(0, 0, cex=10, col='red')

# We can use the pixel correlation function, in particular the FFT output, to assess how
# much further we can afford to push the source extraction in our image.

profound=profoundProFound(image, skycut=2.0, magzero=30, verbose=TRUE, plot=TRUE)
corout_objects_redo=profoundPixelCorrelation(image$imDat, sky=profound$sky,
skyRMS=profound$skyRMS, objects=profound$objects_redo)
magimage(corout_objects_redo$image_sky)
profoundProFound(corout_objects_redo$fft$z, skycut=2, verbose=TRUE, plot=TRUE)

profound=profoundProFound(image, skycut=1.5, magzero=30, verbose=TRUE, plot=TRUE)
corout_objects_redo=profoundPixelCorrelation(image$imDat, sky=profound$sky,
skyRMS=profound$skyRMS, objects=profound$objects_redo)
magimage(corout_objects_redo$image_sky)
profoundProFound(corout_objects_redo$fft$z, skycut=2, verbose=TRUE, plot=TRUE)

profound=profoundProFound(image, skycut=1.0, magzero=30, verbose=TRUE, plot=TRUE)
corout_objects_redo=profoundPixelCorrelation(image$imDat, sky=profound$sky,
skyRMS=profound$skyRMS, objects=profound$objects_redo)
magimage(corout_objects_redo$image_sky)
profoundProFound(corout_objects_redo$fft$z, skycut=2, verbose=TRUE, plot=TRUE)

profound=profoundProFound(image, skycut=0.8, magzero=30, verbose=TRUE, plot=TRUE)
corout_objects_redo=profoundPixelCorrelation(image$imDat, sky=profound$sky,
skyRMS=profound$skyRMS, objects=profound$objects_redo)
magimage(corout_objects_redo$image_sky)
profoundProFound(corout_objects_redo$fft$z, skycut=2, verbose=TRUE, plot=TRUE)

profound=profoundProFound(image, skycut=0.6, magzero=30, verbose=TRUE, plot=TRUE)
corout_objects_redo=profoundPixelCorrelation(image$imDat, sky=profound$sky,
skyRMS=profound$skyRMS, objects=profound$objects_redo)
magimage(corout_objects_redo$image_sky)
profoundProFound(corout_objects_redo$fft$z, skycut=2, verbose=TRUE, plot=TRUE)

# By doing ProFoundsource detection on the FFT itself it tells us if there are significant
# sources of a certain common scale (usually small) still in the image to extract.
# The levels above suggest we cannot push much further than a skycut=1.0. Clearly using
# skycut=0.6 introduces a lot of fake sources.

# We can improve the sky using profoundSkySplitFFT

profound=profoundProFound(image, type="bicubic")
newsky=profoundSkySplitFFT(image$imDat, objects=profound$objects_redo, sky=profound$sky,
skyRMS=profound$skyRMS)

# For convenience, the above is the same as running:

newsky=profoundSkySplitFFT(profound=profound)

# For super added convenience you can also un:

newsky=profoundSkySplitFFT(profound)

# Old versus new sky:

magimage(profound$sky)
magimage(newsky$sky)

# Original image, old sky subtraction and new sky subtraction (pretty subtle!):

magimage(image$imDat)
magimage(image$imDat-profound$sky)
magimage(image$imDat-newsky$sky)

# Be warned, you need a reasonable estimate of the sky and objects before running this.
# If we run on the original image that even the high/low k modes look very odd:

magimage(profoundSkySplitFFT(image$imDat)$sky_lo)
magimage(profoundSkySplitFFT(image$imDat)$sky_hi)

## End(Not run)

ProFound documentation built on Jan. 8, 2021, 5:37 p.m.