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

1 次查看(过去 30 天)
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 个评论
Guillaume
Guillaume 2016-6-16
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?

请先登录,再进行评论。

回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by