フィルターのクリア

xor value always get zero

3 ビュー (過去 30 日間)
ARJUN K P
ARJUN K P 2016 年 2 月 10 日
コメント済み: the cyclist 2016 年 2 月 10 日
img=img('lena.bmp');
i=10;
j=10;
img(i,j)
the result is 158
after i xor with 255
xor(img(i,j),255)
the result is wrong... always get zero...
how to get correct xored value?
  1 件のコメント
the cyclist
the cyclist 2016 年 2 月 10 日
I don't think I would say that the result is wrong. I would say that the xor function doesn't do what you think it does.
Can you tell us what you need your function to actually do?

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

採用された回答

Guillaume
Guillaume 2016 年 2 月 10 日
xor is a logical operator that either return 0 (if both inputs are 0 or both inputs are not 0) or 1 (if one of the input is 0 but not the other).
I strongly suspect that you're wanting to perform a binary xor which is achieved with bitxor:
>>bitxor(158, 255)
ans =
97
See the list of bit-wise operators
  1 件のコメント
the cyclist
the cyclist 2016 年 2 月 10 日
Upvote for you, my friend. I bet you're right, I was confident there was a function for it, and I wish I had known it. :-)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeModify Image Colors についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by