import_jpg1: Extract outline coordinates from a single .jpg file

View source: R/babel-import.R

import_jpg1R Documentation

Extract outline coordinates from a single .jpg file

Description

Used to import outline coordinates from .jpg files. This function is used for single images and is wrapped by import_jpg. It relies itself on import_Conte

Usage

import_jpg1(
  jpg.path,
  auto.notcentered = TRUE,
  fun.notcentered = NULL,
  threshold = 0.5,
  ...
)

Arguments

jpg.path

vector of paths corresponding to the .jpg files to import, such as those obtained with list.files.

auto.notcentered

logical if TRUE random locations will be used until one of them is (assumed) to be within the shape (because it corresponds to a black pixel) and only if the middle point is not black; if FALSE a locator will be called, and you will have to click on a point within the shape.

fun.notcentered

NULL by default but can accept a function that, when passed with an imagematrix and returns a numeric of length two that corresponds to a starting point on the imagematrix for the Conte algorithm. A while instruction wraps it, so the function may be wrong in proposing this starting position. See the examples below for a quick example.

threshold

the threshold value use to binarize the images. Above, pixels are turned to 1, below to 0.

...

arguments to be passed to read.table, eg. 'skip', 'dec', etc.

Details

jpegs can be provided either as RVB or as 8-bit greylevels or monochrome. The function binarizes pixels values using the 'threshold' argument. It will try to start to apply the import_Conte algorithm from the center of the image and 'looking' downwards for the first black/white 'frontier' in the pixels. This point will be the first of the outlines. The latter may be useful if you align manually the images and if you want to retain this information in the consequent morphometric analyses.

If the point at the center of the image is not within the shape, i.e. is 'white' you have two choices defined by the 'auto.notcentered' argument. If it's TRUE, some random starting points will be tried until on of them is 'black' and within the shape; if FALSE you will be asked to click on a point within the shape.

If some pixels on the borders are not white, this functions adds a 2-pixel border of white pixels; otherwise import_Conte would fail and return an error.

Finally, remember that if the images are not in your working directory, list.files must be called with the argument full.names=TRUE!

Note that the use of the fun.notcentered argument will probably leads to serious headaches and will probably imply the dissection of these functions: import_Conte, img_plot and import_jpg itself

Value

a matrix of (x; y) coordinates that can be passed to Out

Note

Note this function will be deprecated from Momocs when Momacs and Momit will be fully operationnal.

See Also

import_jpg, import_Conte, import_txt, lf_structure. See also Momocs' vignettes for data import.

Other import functions: import_Conte(), import_StereoMorph_curve1(), import_jpg(), import_tps(), import_txt(), pix2chc()


vbonhomme/Momocs documentation built on Nov. 13, 2023, 8:54 p.m.