general mask hsv implementation