threshold_image_list {bwimage}R Documentation

Image to matrix - List


Convert two or more images into a list of matrices


threshold_image_list(list_names, filetype = "jpeg",
  compress_method = "none", compress_rate = 1, target_width = 100,
  target_height = 100, threshold_value = 0.5,
  transparency_regulation = 0.5, channel = "rgb")



An object contains the names of the files.


Type of the file to be load. Compatible file types: ".JPGE", ".JPG" or ".PNG".


For high resolution files, i.e. numbers of pixels in width and height, it is suggested to reduce the resolution to create a smaller matrix, it strongly reduce GPU usage and time necessary to run analyses. On the other hand, by reducing resolution, it will also reduce the accuracy of data description. The available methods for image reduction are: i) frame_fixed, which resamples images to a desired target width and height; ii) proportional, which resamples the image by a given ratio provided in the argument "proportion"; iii) width_fixed, which resamples images to a target width, and also reduces the image height by the same factor. For instance, if the original file had 1000 pixels in width, and the new width_was set to 100, height will be reduced by a factor of 0.1 (100/1000); and iv) height_fixed, analogous to width_fixed, but assumes height as reference.


Compress rate to by apply if compress_method=proportional. Note: it should be ser as number range from 0 to 1 .


Target width to be used if compress_method=frame_fixed or compress_method= width_fixed.


Target height to be used if compress_method=frame_fixed or compress_method= height_fixed.


For each pixel, the intensity of color channels (red, green and blue) are averaged and compared to a threshold_value (threshold). If the average intensity is less than the threshold_value (default is 0.5) the pixel will be set as black, otherwise it will be white. See channel argument.


For PNG images, the alpha channel is used to set transparent pixels, i.e. alpha channel values above transparency_regulation (a threshold) will set the pixel as transparent, default is 0.5. NOTE: In the data matrix the value 1 represents black pixels, 0 represents white pixels and NA represents transparent pixels.


RGB channel to be considered in threshold. If channel=RGB (default), the intensity of red, green and blue is averaged and compared to threshold_value. If the average intensity is less than the threshold_value (default is 50 If only one channel is defined ("R" for red, "G" for green, and "B" for blue), the average intensity selected channel compared direct to the threshold_value value.


A matrix of 0, 1 and NA representing white, black and transparent pixels, respectively.


Carlos Biagolini-Jr.

See Also



# Image examples provided by bwimage package
bush<-system.file("extdata/bush.JPG",package ="bwimage")
canopy<-system.file("extdata/canopy.JPG",package ="bwimage")

# Convert images to a list of matrices
working_matrices<-threshold_image_list(c(bush,canopy), "jpeg", "proportional", compress_rate = 0.1)

[Package bwimage version 1.3 Index]