I want to translate a matlab code into c++ opencv, it threshold a RGB image: red value>threshold1 AND red/green>threshold2 AND red/blue>threshold3
The matlab code is:
bw=(im(:,:,1)>=red_th&(im(:,:,1)./im(:,:,2))>=red_green_th&(im(:,:,1)./im(:,:,3))>=red_blue_th);
Where im(:,:,1), im(:,:,2) and im(:,:,3) is the r, g, b value respectively.
I found the matlab code is very efficient comparing with looping all pixels using "for cols and for rows". Hence, I want to find similar efficient method in opencv instead of looping cols and rows.
I read some information about cv::threshold and inRange, however, it seems that they cannot satisfy my requirement.