View source: R/profoundApplyMask.R
profoundApplyMask | R Documentation |
Allows the application of a scale-able and rotate-able mask to an image.
profoundApplyMask(image = NULL, mask = 'disc', xcen = xsize/2, ycen = ysize/2,
xsize = 101, ysize = 101, rot = 0, direction = 'backward', dim = c(101, 101))
profoundMakeMask(size = 101, shape = 'disc')
profoundDrawMask(image, poly = NULL, invert_mask = FALSE, mode = 'draw', type = 'pix',
poly.col = 'red', ...)
image |
Numeric matrix or Rfits_image; the image we want to apply the mask to. If provided this will be used to compute the dim also. |
mask |
Numeric matrix or scalar character; the input mask. If a matrix input, any values above 0 will be considered pixels that we wisk to mask. Note for centreing to make sense the provided mask should nearly always be odd dimensions (since even dimensions will have ambiguous application solutions at pixel centres). If character then an internal mask maker is called as per |
xcen |
Numeric scalar/vector; the x position to centre the mask at (i.e. it will be centred on dim(mask)[1]/2). If a vector then multiple masks will be applied to the image. |
ycen |
Numeric scalar/vector; the y position to centre the mask at (i.e. it will be centred on dim(mask)[2]/2). If a vector then multiple masks will be applied to the image. If xcen is a vector and ycen is scalar then the value of ycen will be repeated as required. |
xsize |
Numeric scalar/vector; the x size we wish the final mask to be. Note this operation is carried out before any rotation. This can be used to (e.g.) distort an input circle to an ellipse. If a vector then multiple masks will be applied to the image. If xcen is a vector and xsize is scalar then the value of xsize will be repeated as required. |
ysize |
Numeric scalar/vector; the y size we wish the final mask to be. Note this operation is carried out before any rotation. This can be used to (e.g.) distort an input circle to an ellipse. If a vector then multiple masks will be applied to the image. If xcen is a vector and ysize is scalar then the value of ysize will be repeated as required. |
rot |
Numeric scalar/vector; anti-clockwise rotation to apply to the mask. Note this operation is carried out after any re-sizing operation. If a vector then multiple masks will be applied to the image. If xcen is a vector and rot is scalar then the value of rot will be repeated as required. |
direction |
Character scalar/vector; "forward" or "backward", see |
dim |
Integer vector; the dimension of the complex mask to return. This is used if image is not provided. |
size |
Integer scalar; the size (e.g. width/diameter) of the dilation kernel in pixels. Should be an odd number else will be rounded up to the nearest odd number. |
shape |
Character scalar; the shape of the dilation kernel. Options are 'box', 'disc', 'diamond', 'Gaussian', 'line'. |
poly |
Data.frame; contains minimally named x/y or RA/Dec polynomial mask vertices (and possibly both). Note pixel centres are half integer, e.g. the centre of the bottom-left pixel is [0.5,0.5]. |
invert_mask |
Logical; if invert_mask is FALSE then pixels inside the polygon are masked (e.g. to remove bright stars etc), if TRUE then pixels outside the polygon are masked (e.g. you only want to consider pixels belonging to a galaxy or cluster region etc). |
mode |
Character scalar; how to compute the mask. Options are 'draw', where users can then click on the image to define the mask region, or 'apply' where the user supplied poly will be used to mask pixels. |
type |
Character scalar; the coordinates to use. Options are 'pix' where the named x/y columns in poly are used to define the mask (ignoring RA/Dec even if present) or 'coord' where the named RA/Dec columns in poly are used to define the mask (ignoring x/y even if present). Note pixel centres are half integer, e.g. the centre of the bottom-left pixel is [0.5,0.5]. If type = 'coord' then the input image must be type Rfits_image (i.e. have a valid WCS). |
poly.col |
Colour of the overlaid polygon defining the mask region. |
... |
Additional arguments to pass on to the image plotting routine. |
The masked values in the target output image are simply set to NA.
When using vector arguments to apply multiple masks, xcen is used to define the number to apply. Other scalar valued inputs are repeated to match the length of xcen. In general you minimally need to provide xcen and ycen vectors, since positions to mask will usually be distributed around the target image.
For profoundApplyMask
a list containing:
mask |
The final complex mask. Each masked region has a unique integer ID (the position within the xcen vector), where lower valued regions take precendence in overlap regions. |
image |
Same as the input image (if provided), except pixels flagged as masked based on the provided information are set to NA. |
For profoundDrawMask
a list containing:
mask |
The final boolean mask based on the drawn or provided (via poly) mask polygon. |
image |
Same as the input image (if provided), except pixels flagged as masked based on the provided information are set to NA. |
poly |
Data.frame of mask vertices x/y and possibly RA/Dec (if appropriate). |
Aaron Robotham
profoundEllipseSeg
image = Rfits_read_image(system.file("extdata", 'VIKING/mystery_VIKING_Z.fits',
package="ProFound"))$imDat
magimage(image)
mask_sq = matrix(1, 101, 101)
magimage(profoundApplyMask(image, mask_sq, 100.5, 100.5)$image)
magimage(profoundApplyMask(image, mask_sq, 100.5, 100.5, xsize=51)$image)
magimage(profoundApplyMask(image, mask_sq, 100.5, 100.5, xsize=51, rot=20)$image)
magimage(profoundApplyMask(image, mask_sq, 100.5, 100.5, xsize=51, rot=90)$image)
mask_circ = profoundEllipseSeg(dim = c(101,101))
magimage(profoundApplyMask(image, mask_circ, 100.5, 100.5, xsize=51, rot=20)$image)
image = Rfits_read_image(system.file("extdata", 'VIKING/mystery_VIKING_Z.fits',
package="ProFound"))
# we will pretend we have already drawn a mask and got our vertices
poly = data.frame(RA = c(352.2922, 352.2958, 352.2954, 352.2904, 352.2870, 352.2872),
Dec = c(-31.81325, -31.81332, -31.81657, -31.81794, -31.81763, -31.81461)
)
mask_coord = profoundDrawMask(image, poly=poly, mode='apply', type='coord')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.