Motion detection using morphology transformation