images={} for k=1:size(file_struct,2) images{k}=file_struct(k).ImData; end images = images'; RGB_images = {} clear k for k=1:size(images) image=images{k}; border_rows = extractfield(file_struct(k), 'border_rows'); RGB_image = line_drawer(image, red_rows, border_rows); RGB_images{k}=RGB_image; clear image clear border_rows end %the montage function is screwing up the colors somehow... montage(RGB_images)