# Revision history [back]

### How to make Otsu threshold locally?

hi all, I have a depth camera and I have to segment hand as foreground for hand detection application, I find that Otsu is really good. says:

threshold( src, dst, 0, 255, THRESH_BINARY|THRESH_OTSU);


but there is a hand overlap with the body, in the threshold image the otsu cannot segment it.

now I divid the image into about 100 Rect as roi and do OTSU

it's like something I want: after getting the foreground (body), if there is a hand, make the body part behind the hand different color. then I can segment the hand overlap with the body.

however, this method is not smart and the image is too ugly , I had tried to make the otsu method like a filter and compare the pixel one by one, but it is too slow.

Is any smarter way to do this? thanks for any advice!

### How to make Otsu threshold locally?

hi all, I have a depth camera and I have to segment hand as foreground for hand detection application, I find that Otsu is really good. says:

threshold( src, dst, 0, 255, THRESH_BINARY|THRESH_OTSU);


a threshold almost done everything I want.

but there is a hand overlap with the body, in the threshold image the otsu cannot segment it.

now I divid the image into about 100 Rect as roi and do OTSU

it's like something I want: after getting the foreground (body), if there is a hand, make the body part behind the hand different color. then I can segment the hand overlap with the body.

however, this method is not smart and the image is too ugly , I had tried to make the otsu method like a filter and compare the pixel one by one, but it is too slow.

Is any smarter way to do this? thanks for any advice!

### How to make Otsu threshold locally?

hi all, I have a depth camera and I have to segment hand as foreground for hand detection application, I find that Otsu is really good. says:

threshold( src, dst, 0, 255, THRESH_BINARY|THRESH_OTSU);


a threshold almost done everything I want.

but there is a hand overlap with the body, in the threshold image the otsu cannot segment it.

now I divid the image into about 100 Rect as roi and do OTSU

it's like something I want: after getting the foreground (body), if there is a hand, make the body part behind the hand different color. then I can segment the hand overlap with the body.

however, this method is not smart and the image is too ugly , I had tried to make the otsu method like a filter and compare the pixel one by one, but it is too slow.

Is any smarter way to do this? thanks for any advice!

edit:

origin image:

depth image:

IR image:

for de-noising purpose I use IR image to do a Otsu and get a mask, then use the mask to cut out the depth image to get a lesser noise depth image, then I use Otsu again in Depth image to get the foreground.

### How to make Otsu threshold locally?

hi all, I have a depth camera and I have to segment hand as foreground for hand detection application, I find that Otsu is really good. says:

threshold( src, dst, 0, 255, THRESH_BINARY|THRESH_OTSU);


a threshold almost done everything I want.

but there is a hand overlap with the body, in the threshold image the otsu cannot segment it.

now I divid the image into about 100 Rect as roi and do OTSU

it's like something I want: after getting the foreground (body), if there is a hand, make the body part behind the hand different color. then I can segment the hand overlap with the body.

however, this method is not smart and the image is too ugly , I had tried to make the otsu method like a filter and compare the pixel one by one, but it is too slow.

Is any smarter way to do this? thanks for any advice!

edit:

origin image:image: (not all the same but same result )

depth image:

IR image:

for de-noising purpose I use IR image to do a Otsu and get a mask, then use the mask to cut out the depth image to get a lesser noise depth image, then I use Otsu again in Depth image to get the foreground.