Originally, objects were segmented from the background using a a global threshold computed from the histogram of the input image via Otsu’s Method. This generally worked well but would fail in cases where the foreground object had strong variations in intensity over its body and/or gaps between body parts.
A possible solution had been implemented and is being tested in the current system. The new method combines two different threshold methods using an OR operation on the binary masks. The first mask uses the same threshold as above while the second computes the median and standard deviation of the pixels in the image and defines the threshold as T = median + 0.8*standard_deviation and selects all pixels greater than or equal to that value. This is implemented in the code below.
thresh1 = threshold_otsu(gray_hp)
med_val = np.median(gray_hp)
std_val = np.std(gray_hp)
thresh2 = med_val + std_val
binary = (gray_hp >= thresh1) | (gray_hp >= thresh2)
bw_img2 = morphology.closing(binary,morphology.disk(3))
One nice feature of this method is the the median-based threshold helps fill in dark foreground parts of the images that are below the Ostu threshold. This takes advantage of the fact that we know most pixels in the image are background, and the background level does not change much.
-
This topic was modified 8 years, 5 months ago by
spcadmin.
-
This topic was modified 8 years, 5 months ago by
spcadmin.
-
This topic was modified 8 years, 5 months ago by
spcadmin.
-
This topic was modified 8 years, 5 months ago by
spcadmin.