Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Average of images in a folder

Subject: Average of images in a folder

From: sai

Date: 12 Jul, 2011 23:28:13

Message: 1 of 3

Hi everyone,

  I need help to calculate this,can please anyone help me...I am having around 500 images in a folder.I need to read that folder and performing several calculations on these images.So,now I wrote a program to read that folder.So it worked.And the second thing here is,I need to perform the Averaging,that is,I need to take the average of those all images.And I am getting error in this...so,can anyone help me out in this.


Thanks in advance.

Subject: Average of images in a folder

From: ImageAnalyst

Date: 13 Jul, 2011 00:46:08

Message: 2 of 3

You need to cast your images to single or double before you sum them.
Something like this (untested):
fileCount = 0;
for k = 1 : numberOfImages
  % Get full filename (folder+base name) somehow, then...
  if k == 1
    sumImage = imread(filename{1});
    [rows1 columns1 numberOfColorBands1] = size(sum);
  else
    thisImage = imread(filename{k});
    [rows columns numberOfColorBands] = size(thisImage);
    if rows == rows1 && columns == columns1 && numberOfColorBands ==
numberOfColorBands1
        sumImage = sumImage + single(thisImage);
        fileCount = fileCount + 1;
    else
        uiwait(warndlg('Image sizes do not match'));
   end
  end
end
meanImage = sumImage / fileCount;

Subject: Average of images in a folder

From: sai

Date: 13 Jul, 2011 11:16:11

Message: 3 of 3

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <03e030e8-6d00-497b-9318-8cb47ca0c381@z14g2000yqh.googlegroups.com>...
> You need to cast your images to single or double before you sum them.
> Something like this (untested):
> fileCount = 0;
> for k = 1 : numberOfImages
> % Get full filename (folder+base name) somehow, then...
> if k == 1
> sumImage = imread(filename{1});
> [rows1 columns1 numberOfColorBands1] = size(sum);
> else
> thisImage = imread(filename{k});
> [rows columns numberOfColorBands] = size(thisImage);
> if rows == rows1 && columns == columns1 && numberOfColorBands ==
> numberOfColorBands1
> sumImage = sumImage + single(thisImage);
> fileCount = fileCount + 1;
> else
> uiwait(warndlg('Image sizes do not match'));
> end
> end
> end
> meanImage = sumImage / fileCount;


Hi,

Thank you so much....

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us