why is the differnce in subtracting two images and subtracting two matrices ?

2 ビュー (過去 30 日間)
Pramod Bhat
Pramod Bhat 2011 年 4 月 15 日
Hi, when you subtract two images we get another image which will be having no negative elements in it,ie intensity level below zero is assigned to Zero value. But when we subtract another two matrices,for example a=[1,2,4;4,6,8;6,8,9] and b=[4,6,9;4,1,3;4,2,7] we get another matrix [-3,-4,-5;0,5,4;2,6,2]. but this final matrix has some negative elements. my doubt is that,even if two images are saved in two variables(ie equivalent to two matrices) their subtraction always gives another matrix having no negative elements. but i want to get negative elements after subtracting them how to achieve this in MATLAB ? i need to sum all those -ve elements. plz help me...

採用された回答

Friedrich
Friedrich 2011 年 4 月 15 日
Hi Pramod,
I think this is related due the fact that an image is hold as an uint8 matrix and those have no sign. What you can do to get the negative values is to cast it,e.g. to int16 before:
difference = int16(A) - int16(B);
Friedrich
  1 件のコメント
Pramod Bhat
Pramod Bhat 2011 年 4 月 16 日
Thanks a lot Dear. It is working now. thanks a lot...-)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by