always get 255 in sum
이전 댓글 표시
I am getting the value 255 all the time in the below loop. P is an lena image of size m*n*3 (m=256,n=256). Actually i need the sum of all pixel values in the entire image. sum=0;
for i=1:3
for j=1:256
for k=1:256
sum = sum+P(j,k,i)
end
end
end
Please help me to solve the problem.
댓글 수: 5
KSSV
2017년 12월 18일
Hello....you need not to run a loop to get sum...read the documentation of sum carefully. You can specify the dimensions and get the sum at once.
Roger Stafford
2017년 12월 18일
There is a Matlab function by the name of 'sum' and therefore you should not be using that name for your variable. It can confuse Matlab.
Sneha
2017년 12월 18일
Stephen23
2017년 12월 18일
Do NOT use the variable name sum, as sum is the name of a very important inbuilt function.
Sneha
2017년 12월 18일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Keypoint Detection에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
