Hello all, I am attempting to add several photos such that I can see the distribution of particles in a laser sheet as they exit a converging nozzle. I am having issues arriving at a final composite photo that contains the particles without over-saturating. Below I will post a few of the base photos (there are really several hundred). I will also show two methods I tried out but to no avail. I will detail the methods below next to their code.
Background photo (2/3 of the photos in the dataset are identical to this because the camera was not in sync with the laser pulses):
Particles photo 1:
Particles photo 2:
Method 1: In method 1 I converted the grayscale .bmp images to double (matrices) before handling them and converted them back mat2gray() before using imshow(). I noticed that the particles were bright when the first few photos were added, but they became dark as I progressed the loop. I also attemped a run involving subtracting the background image, but this led to worse results, as everything approached black (commented out in the bottom for-loop).
clear; clc; close all;
image_folder = 'E:\PIV Shakedown 1\run3\Photos';
filenames = dir(fullfile(image_folder,'*.bmp'));
nfiles = length(filenames);
images = cell(1,nfiles);
background = imread('background.bmp');
background = double(background);
for n = 1:nfiles
f = fullfile(image_folder,filenames(n).name);
current_image = imread(f);
current_image = double(current_image);
images{n} = current_image;
end
addition = images{1};
for j = 1:88
addition = addition+images{j+1};
figure()
imshow(mat2gray(addition))
end
background_avg = addition/(j+1);
background_avg = mat2gray(background_avg);
figure()
imshow(mat2gray(addition))
figure()
imshow(background_avg)
figure()
imshow(mat2gray(background))
Resulting addition photos (at different loop iterations)
RUN 1: First addition involves a photo with no particles and one with sparse particles
j=1, first addition: Note that the particles are dimmer. This addition inluded a bright photo like the ones above.
j=5, fifth addition: Notice that the particles are even more dim (even though more particles are added on this 5th addition). Ideally the final photo will look like this but the particles wil be VERY obvious. Instead, after about 50 pictures you cannot distinguish any particles at all due to their continual approach to black in these photos.
Method 2: In method 2 I did not convert the photos to doubles, so I ran into the issue that is the grayscale range (0-255). I.E. 233+234 = 255 due to the cap.
clear; clc; close all;
image_folder = 'E:\PIV Shakedown 1\run3\Photos';
filenames = dir(fullfile(image_folder,'*.bmp'));
nfiles = length(filenames);
background = imread('background.bmp');
images = cell(1,552);
for n = 1:nfiles
f = fullfile(image_folder,filenames(n).name);
current_image = imread(f);
images{n} = current_image;
end
addition = images{1};
for j = 1:250
addition = imadd(addition,images{j+1});
addition = imsubtract(addition,background);
end
figure()
imshow(addition)
After 8 iterations of Method 2:
After 250 iterations of Method 2: Note that it isn't white purely due to particles, but the entire image creeps towards being white.
I appreciate any help!