# calculating error while averaging multiple images

11 views (last 30 days)
Sumera Yamin on 30 Jul 2020 at 4:16
Commented: Walter Roberson about 11 hours ago
Hi, I have a simple problem and needs guidance. I have 15 image files. I want to calculate the average of these images and calculate error on these images. Any help is appreciated.

Walter Roberson about 23 hours ago
Do you want the average of the R, G, and B separately for each image?
Are you asking for averages to be taken over time for each pixel's R, G, B components?
Read the images into a 4D array, rows by columns by colorpanes by image_number . Then mean(Stack,4) or std(Stack, [], 4)

Sumera Yamin about 13 hours ago
Hi, i do not understand your point. i am not very much into image analysis and its terminologies, but i would say what i want to do is average out 10 images and calculate the position of peak intensity in the image with std as the error in the peak average. In terms of R,G and B, i guess i do not want average of R,G and B for each image seperately, rather average of peak intensity/pixel number.
Walter Roberson about 11 hours ago
projectdir = '.'; %directory images are in
dinfo = dir( fullfile(projectdir, '*.png'));
filenames = fullfile(projectdir, {dinfo.name});
nfiles = length(filenames);
image_contents = cell(nfiles,1);
for K = 1 : nfiles
end
fail = false;
try
image_array = cat(4, image_contents{:});
catch ME
fail = true;
fprintf('Images are not all the same size, cannot proceed');
end
if ~fail
mean_img = mean(image_array, 4);
std_img = std(image_array, [], 4);
gray_mean_img = rgb2gray(mean_img);
[peak_gray_value, peak_location_idx] = max(gray_mean_img, 'all');
[peak_row, peak_col] = ind2sub(size(gray_mean_img), peak_location_idx);
end
... but I have a suspicion that when you talk about peak intensity, that you mean you have images that represent graphs of some kind, and that you want to analyze the graphs represented in the images, extracting the data from them.