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
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!