opencv - Convert Non-zero value to one -
in matlab, can utilize logical(img) convert non-zero element one.
is there simple way(i.e. without loop) convert non-zero stored in cv::mat 1 in opencv?
thanks!
there number of functions may help depends on have , trying get.
1) opencv has function compare , operator '!=' (as other operator may need). can write:
img = (img != 0); this convert non-zero value of matrix 255. know wanted convert 1, if 255 plenty best method. in task encountered in past conversion 255 improve conversion 1, because can utilize resulting image kinds of bitwise operations logic and, or, etc...
2) if want create conversion 1, , matrix positive integers (or chars, or shorts), can utilize function min.
img = min(img,1); 3) can utilize function threshold @roger rowland suggested.
opencv
No comments:
Post a Comment