[mmreadgray] [Up] [mmis] | Relations |
Implemented in Python.
f1 | Image Gray-scale (uint8 or uint16) or binary image. |
oper | String relationship from: '==', '~=', '<','<=', '>', '>='. |
f2 | Image Gray-scale (uint8 or uint16) or binary image. |
oper1 | String relationship from: '==', '~=', '<','<=', '>', '>='. Default:
|
f3 | Image Gray-scale (uint8 or uint16) or binary image.
Default:
|
y | Image Binary image. |
Apply the relation
oper
to each pixel of images
f1
and
f2
, the result is a binary image with the same size. Optionally, it is possible to make the comparison among three image. It is possible to use a constant value in place of any image, in this case the constant is treated as an image of the same size as the others with all pixels with the value of the constant.
>>> print mmcmp(uint8([1, 2, 3]),'<', uint8(2))
[1 0 0]
>>> print mmcmp(uint8([1, 2, 3]),'<', uint8([0, 2, 4]))
[0 0 1]
>>> print mmcmp(uint8([1, 2, 3]),'==', uint8([1, 1, 3]))
[1 0 1]
def mmcmp(f1, oper, f2, oper1=None, f3=None): if oper == '==': y = (f1==f2) elif oper == '~=': y = (f1!=f2) elif oper == '<=': y = (f1<=f2) elif oper == '>=': y = (f1>=f2) elif oper == '>': y = (f1> f2) elif oper == '<': y = (f1< f2) else: assert 0, 'oper must be one of: ==, ~=, >, >=, <, <=, it was:'+oper if oper1 != None: if oper1 == '==': y = mmintersec(y, f2==f3) elif oper1 == '~=': y = mmintersec(y, f2!=f3) elif oper1 == '<=': y = mmintersec(y, f2<=f3) elif oper1 == '>=': y = mmintersec(y, f2>=f3) elif oper1 == '>': y = mmintersec(y, f2> f3) elif oper1 == '<': y = mmintersec(y, f2< f3) else: assert 0, 'oper1 must be one of: ==, ~=, >, >=, <, <=, it was:'+oper1 y = mmbinary(y) return y
mmis | Verify if a relationship among images is true or false. |
mmthreshad | Threshold (adaptive) |
mmfreedom | Control automatic data type conversion. |
[mmreadgray] [Up] [mmis] | ![]() |
Copyright (c) 2003, Roberto A. Lotufo, UNICAMP-University of Campinas; Rubens C. Machado, CenPRA-Renato Archer Research Center. |