calculating error while averaging multiple images
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Sumera Yamin
el 30 de Jul. de 2020
Comentada: Image Analyst
el 17 de Ag. de 2020
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.
0 comentarios
Respuesta aceptada
Walter Roberson
el 9 de Ag. de 2020
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)
12 comentarios
Walter Roberson
el 12 de Ag. de 2020
function [imageData, imgstd] = meanImage(path, fileNamePrefix, fileNameSufix, n, mStart, mEnd)
N = mEnd - (mStart - 1);
currentImage = double(loadImage(path, fileNamePrefix, fileNameSufix, n, mStart));
imgsum = currentImage;
imgsqsum = imgsum.^2;
for mm = (mStart+1):mEnd
currentImage = double(loadImage(path, fileNamePrefix, fileNameSufix, n, mm));
imgsum = imgsum + currentImage;
imgsqsum = imgsqum + currentImage.^2;
end
mean_img = imgsum ./ N;
imageData = cast(mean_img, class(currentImage));
imgstd = sqrt((imgsqsum - 2 .* mean_img .* imgsum + mean_img.^2) ./ (N-1));
end
This code deliberately turns the mean image back into the datatype of the individual images, such as uint8. This is because it calculates the mean image in the same units as the original image, not in terms of the 0 to 1 range that could be used instead. Whether this is best for you depends on what you want to do with the mean image.
Más respuestas (2)
Image Analyst
el 10 de Ag. de 2020
Editada: Image Analyst
el 12 de Ag. de 2020
See my attached demo. It averages RGB and gray scale images and gives statistics about them.. Adapt as needed.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/345207/image.png)
11 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!