Is there a function that can calculate the standard deviation of an 3D array from a provided mean matrix?

15 visualizzazioni (ultimi 30 giorni)
I want to calculate the standard deviation of multiple 3D arrays, each containing depth information for multiple frames. As I have multiple recordings, each in a seperate array, I calculated the mean values for each pixel of all recordings together, receiving a 2D array. Now I want to plot the standard deviation for each recording (array) from this mean 2D array, instead of calculating the standard deviation from the mean values within one recording.
Therefore, as far as I understand, I cant use:
std('3D-array', 1, 3)
So do you know any function, that works like std(), but where you can provide the mean values?

Risposte (2)

Walter Roberson
Walter Roberson il 28 Lug 2020
sqrt(sum((Your3DArray - Your2DMeanArray).^2, 3) ./ (size(Your3Darray,3) - 1))
  3 Commenti
Bruno Luong
Bruno Luong il 28 Lug 2020
Modificato: Bruno Luong il 28 Lug 2020
Walter, I agree. I think you should not have -1 if the mean is computed independent of Your3DArray. The -1 is for anti bias only valid if Mean is computed from the data itself.

Accedi per commentare.


Image Analyst
Image Analyst il 28 Lug 2020
It sounds like you have a 3-D array where each slice is a separate image, and you took the mean along the third dimension so that you now have a 2-D array where each pixel is the mean of the pixels of the corresponding column of the 3D array. Is that right? And you have several of these 3-D arrays which are recordings at different times, which means you have several 2-D arrays giving the mean image for each recording.
Now you say "Now I want to plot the standard deviation for each recording (array) from this mean 2D array, instead of calculating the standard deviation from the mean values within one recording." So why can't you just do
stDev = std2(meanImage2D);
? And if you're recalling your 3-D arrays from video files in a loop, why can't you do this for multiple recordings like this:
for k = 1 : numRecordings
array3D = GetThisRecording(k); % Somehow get the kth recording.
meanImage2D = mean(array3D, [], 3); % Get mean image along the 3rd dimension.
stDev(k) = std2(meanImage2D);
imageMeans(k) = mean2(meanImage2D)
end
plot(stDev, 'b-', 'LineWidth', 2);
grid on;
xlabel('Recording number', 'FontSize', 15);
ylabel('Standard deviation of mean image', 'FontSize', 15);
This way you can see how much the variation in your scene (due to noise or some other change in the scene) changes over time as you monitor the mean and stdev of each frame. I've done a similar thing where I've computed the mean of the means, the standard deviation of the means, the mean of the standard deviations, and the standard deviation of the standard deviations. They each tell you a different thing.

Community Treasure Hunt

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

Start Hunting!

Translated by