Binary Image Subtraction

5 views (last 30 days)
Colm
Colm on 9 Feb 2012
I am subtracting one binary image away from another image. But the results seem to be the inverted answer. Bascially in hex 17D8 - 0A5A = D7E but the answer Matlab writes out is FFFFFFFFFFFFF282
This is the same decimal answer except it is negative instead of positive, so: 3454 = D7E & -3454 = FFFFFFFFFFFFF282
Is there some sort of overload? and how do I overcome this problem? As it affects any other image processing I need to preform.
[FileName, PathName] = uigetfile({'*.jpg;*.tif;*.png;*.gif;*.bin','All Image Files';...
'*.*','All Files' },'mytitle');
Full = fullfile(PathName, FileName)
fid = fopen(Full);
samevals = fread(fid, [2048, 2048], 'uint16');
fclose(fid);%load binary
X = samevals;
[FileName2, PathName2] = uigetfile({'*.jpg;*.tif;*.png;*.gif;*.bin','All Image Files';...
'*.*','All Files' },'mytitle');
Full = fullfile(PathName2, FileName2)
fid2 = fopen(Full);
new = fread(fid2, [2048, 2048], 'uint16');
fclose(fid2);%load binary
frametempt=double(X) - double(new);
  2 Comments
Walter Roberson
Walter Roberson on 9 Feb 2012
The most obvious possibility would seem to be that you are not subtracting in the order that you think you are.
Colm
Colm on 10 Feb 2012
I am subtracting in the right order, because I have tried it in the other (wrong) order. At the minute I am getting the right numbers but matlab seems to be putting a negative sign in hex in front of some values.
I'm taking an offset from an image with offset and signal so I should just have signal left, that's how I know what order to subtract in. Thanks though.

Sign in to comment.

Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!