bsxfun@minus and mean does not give the right answer ?
1 view (last 30 days)
Show older comments
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 Comment
Guillaume
on 16 Jun 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?
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!