c++ - Image processing with openCV, color change -


i doing image processing , have black shape on white image. use findcontours() need white shape on black image.

  1. is there way change opencv settings track black shapes on white background instead ?
  2. i managed find white part of image using inrange() change other color, change black part white, , again first part black using inrange(). there easier way convert black white , white black on image @ same time ?

starting binary_image of type cv_8uc1:

  1. you can use binary_not (as suggested @zdar):

    binary_not(binary_image, binary_image); 
  2. invert values aritmtetic operation (as suggested @sunreef):

    binary_image = 255 - binary_image; 
  3. or use not logical operator ~.

    binary_image = ~binary_image; 

    this can nice shortcut if need invert values particular function, e.g.:

    findcontours(~binary_image, ... ); 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -