Converts a PIL Image instance to a matrix.
Arguments
- img
Input PIL Image instance.
- data_format
Image data format, can be either
"channels_first"or"channels_last". Defaults toNULL, in which case the global settingconfig_image_data_format()is used (unless you changed it, it defaults to"channels_last").- dtype
Dtype to use.
NULLand"double"return an R double array."integer"returns an R integer array. All other values (e.g.,"float32") return a NumPy array.
Example
image_path <- get_file(origin = "https://www.r-project.org/logo/Rlogo.png")
(img <- image_load(image_path))array <- image_to_array(img)
str(array)See also
Other image utils: image_array_save() image_from_array() image_load() image_smart_resize() op_image_affine_transform() op_image_crop() op_image_extract_patches() op_image_gaussian_blur() op_image_hsv_to_rgb() op_image_map_coordinates() op_image_pad() op_image_perspective_transform() op_image_resize() op_image_rgb_to_grayscale() op_image_rgb_to_hsv()
Other utils: audio_dataset_from_directory() clear_session() config_disable_interactive_logging() config_disable_traceback_filtering() config_enable_interactive_logging() config_enable_traceback_filtering() config_is_interactive_logging_enabled() config_is_traceback_filtering_enabled() get_file() get_source_inputs() image_array_save() image_dataset_from_directory() image_from_array() image_load() image_smart_resize() layer_feature_space() normalize() pad_sequences() set_random_seed() split_dataset() text_dataset_from_directory() timeseries_dataset_from_array() to_categorical() zip_lists()