How to subtract single element of matrix from any number
1 次查看(过去 30 天)
显示 更早的评论
i am having a matrix 'devi1' and graylevel image 'b'
a variable av2 is having value 79
my code is
b(1,1)=abs(a(1,1)-av2);
currently a(1,1)=0
then b(1,1) should be 78
but it is caming '0'
please help me !
0 个评论
回答(1 个)
Walter Roberson
2019-3-5
abs(double(a(1,1)) - av2)
Your array is uint8. When you subtract a larger value from a uint8 value, then the result does not become negative: the result is uint8 and so the result becomes 0. You need to convert to a signed representation to avoid the problem.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!