[mmcmp] [Up] [mmisbinary] | Relations |
Implemented in Python.
f1 | Image Gray-scale (uint8 or uint16) or binary image. |
oper | String relationship from: '==', '~=', '<','<=', '>', '>=', 'binary', 'gray'. |
f2 | Image Gray-scale (uint8 or uint16) or binary image.
Default:
|
oper1 | String relationship from: '==', '~=', '<','<=', '>', '>='. Default:
|
f3 | Image Gray-scale (uint8 or uint16) or binary image.
Default:
|
y | Double Bool value: 0 or 1 |
Verify if the property or relatioship between images is true or false. The result is true if the relationship is true for all the pixels in the image, and false otherwise. (Obs: This function replaces
mmisequal, mmislesseq, mmisbinary
).
>>> fbin=mmbinary([0, 1])
>>> f1=uint8([1, 2, 3])
>>> f2=uint8([2, 2, 3])
>>> f3=uint8([2, 3, 4])
>>> mmis(fbin,'binary')
1.0
>>> mmis(f1,'gray')
1
>>> mmis(f1,'==',f2)
0.0
>>> mmis(f1,'<',f3)
1.0
>>> mmis(f1,'<=',f2)
1.0
>>> mmis(f1,'<=',f2,'<=',f3)
1.0
def mmis(f1, oper, f2=None, oper1=None, f3=None): from string import upper if f2 == None: oper=upper(oper); if oper == 'BINARY': return mmisbinary(f1) elif oper == 'GRAY' : return not mmisbinary(f1) else: assert 0,'oper should be BINARY or GRAY, was'+oper elif oper == '==': y = mmisequal(f1, f2) elif oper == '~=': y = not mmisequal(f1,f2) elif oper == '<=': y = mmislesseq(f1,f2) elif oper == '>=': y = mmislesseq(f2,f1) elif oper == '>': y = mmisequal(mmneg(mmthreshad(f2,f1)),mmbinary(1)) elif oper == '<': y = mmisequal(mmneg(mmthreshad(f1,f2)),mmbinary(1)) else: assert 0,'oper must be one of: ==, ~=, >, >=, <, <=, it was:'+oper if oper1 != None: if oper1 == '==': y = y and mmisequal(f2,f3) elif oper1 == '~=': y = y and (not mmisequal(f2,f3)) elif oper1 == '<=': y = y and mmislesseq(f2,f3) elif oper1 == '>=': y = y and mmislesseq(f3,f2) elif oper1 == '>': y = y and mmisequal(mmneg(mmthreshad(f3,f2)),mmbinary(1)) elif oper1 == '<': y = y and mmisequal(mmneg(mmthreshad(f2,f3)),mmbinary(1)) else: assert 0,'oper1 must be one of: ==, ~=, >, >=, <, <=, it was:'+oper1 return y
[mmcmp] [Up] [mmisbinary] | ![]() |
Copyright (c) 2003, Roberto A. Lotufo, UNICAMP-University of Campinas; Rubens C. Machado, CenPRA-Renato Archer Research Center. |