Skip to content

Commit

Permalink
Added global otsu thresholding
Browse files Browse the repository at this point in the history
  • Loading branch information
ajinkya-kulkarni committed May 16, 2023
1 parent 29215d1 commit aa4a861
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions PyTextureAnalysis_StreamlitApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@

# Binarize the image

BinarizationKey = 20
# BinarizationKey = 20
# binarized_image = binarize_image(filtered_image, radius = BinarizationKey)

binarized_image = binarize_image(filtered_image, radius = BinarizationKey)
binarized_image = binarize_image(filtered_image)

time.sleep(ProgressBarTime)
ProgressBar.progress(float(3/11))
Expand Down
8 changes: 4 additions & 4 deletions modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from scipy.stats import circmean, circstd
from scipy import signal

from skimage.filters import threshold_mean, gaussian
from skimage.filters import threshold_mean, gaussian, threshold_otsu
from skimage.morphology import disk
from skimage.filters import rank

Expand All @@ -45,7 +45,7 @@

########################################################################################

def binarize_image(image, radius = 15):
def binarize_image(image):
"""
This function checks if the input image is 2D and returns a binary image based on a threshold value.
Expand Down Expand Up @@ -74,7 +74,7 @@ def binarize_image(image, radius = 15):

# global thresholding

threshold_value = threshold_mean(image)
threshold_value = threshold_otsu(image)

############

Expand Down Expand Up @@ -124,7 +124,7 @@ def percentage_area(image):
non_zero_pixels = np.count_nonzero(non_nan_image)

image_size = image.shape[0] * image.shape[1]
percentage_area = np.round(100 * non_zero_pixels / image_size, 2)
percentage_area = np.round(100 * non_zero_pixels / image_size, 1)

return percentage_area

Expand Down

0 comments on commit aa4a861

Please sign in to comment.