Learn R Programming

Momocs (version 0.2-03)

import.jpg: Everything to convert images to a list of coordinates.

Description

Functions to import .jpg images and convert them to list of coordinates.

Usage

import.jpg(jpg.list)
import.multi1.jpg(path)
import.img.prepare(path)
import.img.Conte(img, x, auto=TRUE, plot=TRUE)

Arguments

jpg.list
A vector of character containing the path to your .jpg images.
path
character. A single path to a .jpg image.
img
an imagematrix object.
x
A vector of $(x; y)$ coordinates from where to start Conte algorithm.
auto
logical. Whether to try or not to start at the center of the image(s) before asking the user to click within the shape.
plot
logical. Whether to plot or not the image. Used internally by import.multi1.jpg to not reload the same image.

Value

  • import.jpg returns a list of (from 1 to thousands) $(x; y)$ coordinates arranged as matrices and that can be then converted to a Coo-object. import.multi1.jpg returns a list of $(x; y)$ coordinates. import.img.prepare returns an imagematrix object, import.img.Conte returns a matrix of $(x; y)$ coordinates.

Details

Typically, an object returned by list.files on a folder containing your images is passed to import.jpg. import.img.prepare and import.img.Conte are typically not used by front-user but internally by import.jpg. They clean, binarize, threshold, etc. raw .jpg images and extract a list of coordinates from a black and white imagematrix, respectively. The best option is to work with black and white .jpg image with the black mask of the outline overlapping the center of the image. import.multi1.jpg helps to extract several outlines from the same .jpg image.

Due to troubles with ReadImages and the recent change towards the jpeg package for import of images, they MUST be converted to black and white images before being imported.

See Also

import.txt.

Examples

Run this code
jpg.list <- list.files(path_to_your_folder_containing_.txt_files, full=TRUE)
I <- import.jpg(jpg.list)
Coo(I)

Run the code above in your browser using DataLab