Dynamic threshold value

asked 2012-10-12 11:47:48 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >50 is welcome to improve it.

In my application I have a problem and don't know how to implement my idea in OpenCV. Could you please direct me how to sort out this issue. I want a dynamic threshold based on hue-sat color, so that I can identify specific locations in an image. Following are the threshold values that work fine for different images

// work fine for img1, img2 and img3 but not for img4, img5, img6.
cvInRangeS(imgHSV, cvScalar(5, 70, 179), cvScalar(54, 255, 255), imgThreshed); 

//work fine for img4, img5 but nor for img1,2,3 and 6
cvInRangeS(imgHSV, cvScalar(5, 100, 100), cvScalar(54, 255, 255), imgThreshed); 

// work fine img7 but not for img 1,2,3,4,5,6.
cvInRangeS(imgHSV, cvScalar(5, 96, 140), cvScalar(100, 255, 255), imgThreshed);

cvInRangeS(imgHSV, cvScalar(5, 100, 100), cvScalar(35, 255, 255), imgThreshed); 

cvInRangeS(imgHSV, cvScalar(12, 63 , 128), cvScalar(18, 200, 255), imgThreshed);

cvInRangeS(imgHSV, cvScalar(5, 70, 160), cvScalar(100, 255, 255), imgThreshed);

I need a generalized approach so that hue-sat can max and min value can be extracted and put in cvInranges() during run time. So far I studied I found that there is a histogram that can be used to determine hue-sat of the image.

Could you please guide me or refer me how to get hue-sat maximum and minimum value of specific region during run time so that I can generalize my application.

edit retag flag offensive close merge delete

Comments

hm, do you mean something like Otzu method?

yes123 gravatar imageyes123 ( 2012-10-15 04:18:19 -0500 )edit

I am new to opencv and to image processing, I need a solution to the above scenario and stuck there. In my work i have to extract region of a palm that is pressed against a glass [ the pressed regions are different to the unpressed region of palm in color ] but the palm color of all human race are not exactly the same in color, that's why the above threshold values (given in question) are specific for specific human race. I want to get threshold value during run time automatically rather than giving it in design time. If otzu is the solution to above problem then can i have any example code in opencv please.

zia gravatar imagezia ( 2012-10-15 10:17:29 -0500 )edit