utils_measures {pliman}R Documentation

Utilities for object measures

Description

Usage

get_measures(
  object,
  measure = NULL,
  id = NULL,
  dpi = NULL,
  sep = "\\_|-",
  verbose = TRUE,
  digits = 5
)

plot_measures(
  object,
  measure = "id",
  id = NULL,
  hjust = NULL,
  vjust = NULL,
  digits = 2,
  size = 0.9,
  col = "white",
  ...
)

Arguments

object

An object computed with analyze_objects().

measure

For plot_measures(), a character string; for get_measures(), a two-sided formula, e.g., measure = area ~ 100 indicating the known value of object id. The right-hand side is the known value and the left-hand side can be one of the following.

  • area The known area of the object.

  • perimeter The known perimeter of the object.

  • radius_mean The known radius of the object.

  • radius_min The known minimum radius of the object. If the object is a square, then the radius_min of such object will be L/2 where L is the length of the square side.

  • radius_max The known maximum radius of the object. If the object is a square, then the radius_max of such object according to the Pythagorean theorem will be ⁠L x sqrt(2) / 2⁠ where L is the length of the square side.

id

An object in the image to indicate a known value.

dpi

A known resolution of the image in DPI (dots per inch).

sep

Regular expression to manage file names. The function combines in the merge object the object measures (sum of area and mean of all the other measures) of all images that share the same filename prefix, defined as the part of the filename preceding the first hyphen (-) or underscore (_) (no hyphen or underscore is required). For example, the measures of images named ⁠L1-1.jpeg⁠, ⁠L1-2.jpeg⁠, and ⁠L1-3.jpeg⁠ would be combined into a single image information (L1). This feature allows the user to treat multiple images as belonging to a single sample, if desired. Defaults to sep = "\\_|-".

verbose

If FALSE, runs the code silently.

digits

The number of significant figures. Defaults to 2.

hjust, vjust

A numeric value to adjust the labels horizontally and vertically. Positive values will move labels to right (hjust) and top (vjust). Negative values will move the labels to left and bottom, respectively.

size

The size of the text. Defaults to 0.9.

col

The color of the text. Defaults to "white".

...

Further arguments passed on to graphics::text().

Value

Author(s)

Tiago Olivoto tiagoolivoto@gmail.com

Examples


library(pliman)
img <- image_pliman("objects_300dpi.jpg")
plot(img)
# Image with four objects with a known resolution of 300 dpi
# Higher square: 10 x 10 cm
# Lower square: 5 x 5 cm
# Rectangle: 4 x 2 cm
# Circle: 3 cm in diameter

# Count the objects using the blue band to segment the image
results <-
   analyze_objects(img,
                 index = "B",
                 lower_noise = 0.1)
plot_measures(results, measure = "id")

# Get object measures by declaring the known resolution in dots per inch
(measures <- get_measures(results, dpi = 300))

# Calculated diagonal of the object 1
# 10 * sqrt(2) = 14.14

# Observed diagonal of the object 1
measures[1, "radius_max"] * 2


# Get object measures by declaring the known area of object 1
get_measures(results,
             id = 1,
             area ~ 100)




[Package pliman version 2.1.0 Index]