Finding the mean of a group of images?

1 visualización (últimos 30 días)
Mohammed Hammouda
Mohammed Hammouda el 9 de Mzo. de 2021
Comentada: Mohammed Hammouda el 9 de Mzo. de 2021
Hello everyone,
So I am trying to find the mean of a group of images so I can compare their mean before and after the filter.
for l = 1:numel(bmpFiles)
%applying the filter
bflt_img1{l} = bfilter2(img1{l},w,sigma);
%finding the average of the images
I0 = imread(img1{l});
sumImage = double (I0)
grayImage = imread(img1{l+1});
sumImage = sumImage + double(grayImage);
meanImage = sumImage / numel(bmpFiles);
end
However, I get this error message:
Error using imread>parse_inputs (line 504)
The file name or URL argument must be a character vector or string scalar.
Error in imread (line 342)
[source, fmt_s, extraArgs, was_cached_fmt_used] = parse_inputs(cached_fmt, varargin{:});
Error in bil1_MH (line 21)
I0 = imread(img1{l});
Is there a problem with using img1{L} as a format to refer to the image?
Thanks in advance.

Respuesta aceptada

Walter Roberson
Walter Roberson el 9 de Mzo. de 2021
bfilter2() is not part of MATLAB, so we do not know what it does. There is a File Exchange contribution https://www.mathworks.com/matlabcentral/fileexchange/12191-bilateral-filtering but it would give an error if img1{l} were not floating point. Either you are using a different bfilter2() or else img1{l} is floating point.
If img1{l} is floating point, that would explain the error message when you tried to imread() it. If you have already read the data into img1 then just
I0 = img1{l};
  3 comentarios
Walter Roberson
Walter Roberson el 9 de Mzo. de 2021
If you have a group of images that are all the same size in a cell array img1 then skip the loop and do
nd = ndims(img1{1});
mean_image = mean(cat(nd+1, img1{:}), nd+1);
Mohammed Hammouda
Mohammed Hammouda el 9 de Mzo. de 2021
Thank you very much for your answers. Apologies for not making my question clear enough and suspect to multiple assumptions. My images were already read so I just used your suggestion to go with
I0 = img1{l};
Thank you very much!! I hope I did not keep you waiting long for replying!

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by