Finding the mean of a group of images?
1 view (last 30 days)
Show older comments
Mohammed Hammouda
on 9 Mar 2021
Commented: Mohammed Hammouda
on 9 Mar 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.
0 Comments
Accepted Answer
Walter Roberson
on 9 Mar 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 Comments
Walter Roberson
on 9 Mar 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);
More Answers (0)
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!