Standard Deviation Between images

9 vues (au cours des 30 derniers jours)
Robert Roy
Robert Roy le 9 Mai 2016
Modifié(e) : Guillaume le 10 Mai 2016
Hi there,I currently have set of images which I get from taking the average from a group of smaller images, I am just wondering if it is possible if I could get an array of the std deviation between the images from n2 to n1? Everytime I try I end up taking just the Overall Standard Deviation from the image
if true
for n=n1:n2
stem='E:\29th April New\NEW Gain=99_No Delay_ Gate=0.02_0';
r=n-1;
r=int2str(r);
combinedStr=strcat(stem,r);
Images=99;
t=10;
AvgImg =(zeros(1024,1280));
for i=t:Images;
B=readimx(fullfile(combinedStr,['B000',int2str(i),'.im7']));
C=B.Frames{1}.Components{1};
V = C.Planes;
Img = V{1,1};
J = imrotate(Img,-90);
I2 =(flip(J,2));
FUNC=@(x)max(x(:));
I3=medfilt2(I2,[1 1]);
AvgImg = AvgImg +double(I3);
end
figure(n-1)
AverageImg = AvgImg/(Images-t);
AverageImgB=90;
AverageImgLII=uint16(AverageImg-AverageImgB);
K=imagesc(flipud(AverageImgLII));
set(gca,'YDir','normal');
end

Réponse acceptée

Guillaume
Guillaume le 9 Mai 2016
Modifié(e) : Guillaume le 10 Mai 2016
Store your images in a 3D matrix and calculate all your stats in one go using mean, std, etc. on the 3rd dimensions:
numimages = 99
stem = 'E:\29th April New\NEW Gain=99_No Delay_ Gate=0.02_0';
for gating = n1:n2
stemgating = sprintf('%s%d', stem, gating-1);
LIIimages = cell(1, numimages); %storing in a cell array, to be converted to 3D matrix later on
for imgindex = 1:numimages
imxstruct = readimx(fullfile(stemgating, sprintf('B%05d.im7', imgindex)));
img = imxstruct.Frames{1}.Componenets{1}.Planes{1};
LIIimages{imgindex}= imrotate(img, -90);
end
%convert cell array to 3d matrix
LIIimages = cat(3, LIIimages{:});
%calculate stats:
meanimg = mean(LIIimages, 3);
stdimg = std(LIIimages, 0, 3);
%... do more stuff
end
Note that I'm storing the images temporarily into a cell array. This avoids having to hardcode the size of the images (the alternative is to predeclare the 3D array with zeros(1024, 1280, numimages))
Also note, that I've fixed the problem with you not being able to create properly the name of the first 9 buffer images by using sprintf with a format string that says to prepend the number with enough zeros to have 5 digit (the '%05d')
  6 commentaires
Robert Roy
Robert Roy le 10 Mai 2016
Thats brillant thanks very much, one of the things I would also like to do is to plot each individual image gating to compare against the average value, is there a way to do this?
Guillaume
Guillaume le 10 Mai 2016
I'm not sure what you mean by plotting an image against another.
Note that all the images are held in LIIimages. image number n is LIIimages(:, :, n). You can display these however you want.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by