import multiple .tiff images into a structure, with fields that are user inputed in matlab

You can use the imread function to read multiple .tiff images and store them in a MATLAB structure. You can use input function to accept user inputs and create fields in the structure.

Here's an example code:

main.m
% Get user input
num_images = input('Enter the number of images: ');

% Create empty structure
image_struct(num_images) = struct('data', [], 'name', '');

% Loop through each image
for i = 1:num_images
    % Get user input for image name
    image_name = input(sprintf('Enter the name of image %d: ', i), 's');
    % Read the image
    image_data = imread(image_name);
    % Store the data and name in the structure
    image_struct(i).data = image_data;
    image_struct(i).name = image_name;
end
498 chars
17 lines

This code will create a structure image_struct with num_images number of elements. Each element will have two fields, data which stores the image data and name which stores the image file name. The input function is used to get the user input for number of images and image names.

gistlibby LogSnag