How to find the gait energy image(GEI) in matlab from a sequence of gait images saved in a folder?

16 views (last 30 days)
this is the gait sequence attached here
  4 Comments
Walter Roberson
Walter Roberson on 31 Aug 2017
Those images appear to already be grayscale to me. However, on the chance they are not, you could use rgb2gray() on the image.
Put all the images into a 3D array with the third dimension being the image number. Then take mean(The3DArray, 3) to take the mean between the images. Note that the result will be floating point not uint8 so you might want to uint8() the result if you plan to display it.
ankit sharma
ankit sharma on 4 Sep 2017
No.. you are not getting me. Actually let's say i have 10 images in a folder, now i have to convert these images to a single image by averaging the images so that it have features of all 10 images. this is what we call gait energy image. And yeah..Thank you for replying sir

Sign in to comment.

Answers (2)

Gautam
Gautam on 27 Nov 2024 at 4:21
Edited: Gautam on 27 Nov 2024 at 4:23
Hello Ankit
An easy way to accomplish this task is to read all the images you have in the folder and append them into an array and then take the average along the 3rd dimension.
Assuming that all the images are of the same dimension, here’s the code that demonstrates this:
% Reading the images into an array
folderPath = 'path/to/your/folder';
imageFiles = dir(fullfile(folderPath, '*.png'));
imageArray = [];
for k = 1:length(imageFiles)
imagePath = fullfile(folderPath, imageFiles(k).name);
img = imread(imagePath);
% Convert the image to grayscale if it's RGB
if size(img, 3) == 3
img = rgb2gray(img);
end
% Append the image to the array
if isempty(imageArray)
imageArray = img;
else
imageArray = cat(3, imageArray, img);
end
end
% Calculating the average image along the third dimension
averageImage = mean(imageArray, 3);
imshow(uint8(averageImage));
If your images are not of the same size, you can resize them using the “imresize” function
Here are some useful documents that you can refer to:

Image Analyst
Image Analyst on 27 Nov 2024 at 17:06
See attached demo for averaging together all the images in a folder. It will probably work for grayscale images too.

Community Treasure Hunt

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

Start Hunting!