bsxfun@minus and mean does not give the right answer ?

1 vue (au cours des 30 derniers jours)
RuiQi
RuiQi le 16 Juin 2016
Commenté : Guillaume le 16 Juin 2016
I have many images of dimension 3 (RGB) each that are concatenated in the 4th dimension to produce a 4 dimensional matrix named data. Then I subtract each pixel in every image by the mean along the 4th dimension. However, when I sum up the data along the 4th dimension, I do not get an output of zero. I was hoping if someone can point out my mistakes. The code (excluding the reading of data) is written below. Would the error be simply due to rounding errors ?
data = double(cat(4, positive_samples.var(:,:,:,:), negative_samples.var(:,:,:,:)));
dataMean = mean(data, 4);
data = bsxfun(@minus, data, dataMean);
sum(data,4)
  1 commentaire
Guillaume
Guillaume le 16 Juin 2016
If the matrices that you concatenate are indeed 3D, why have you got four colons in
positive_samples.var(:,:,:,:) %implying var is at least 4D
Also, what value is
s = sum(data, 4); %after subtracting the mean
max(s(:)) %what is the maximum deviation from 0?

Connectez-vous pour commenter.

Réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by