Why is my threshold yen and remove small holes and objects not working (im not getting errors) when trying to do it on an image?

113 views Asked by At
import matplotlib.pyplot as plt
import pandas as pd
from skimage import io, morphology, segmentation
from PIL import Image
from skimage.color import rgb2gray
from scipy.ndimage import gaussian_filter
from skimage.filters import threshold_yen
import numpy as np

filepath1 = r'C:\Users\marzo\Downloads\frogblood.jpg'
filepath2 = r'C:\Users\marzo\Downloads\fishblood.jpg'

img1 = io.imread(filepath1)
img2 = io.imread(filepath2)

img1 = rgb2gray(img1)
img2 = rgb2gray(img2)

img1 = gaussian_filter(img1, sigma=1)
img2 = gaussian_filter(img2, sigma=1)

block_size1 = 51
block_size2 = 51

threshold1 = threshold_yen(img1, block_size1)
threshold2 = threshold_yen(img2, block_size2)

mask = img1 < threshold1 * 0.3
mask2 = img2 < threshold2 * 0.89

mask = morphology.remove_small_objects(mask, 400)
mask2 = morphology.remove_small_objects(mask2, 10000)
mask = morphology.remove_small_holes(mask, 10000)
mask2 = morphology.remove_small_holes(mask2, 2)

plt.title('Frog Blood_20x')
plt.imshow(img1)
plt.show()
plt.title('Fish Blood_20x')
plt.imshow(img2)
plt.show()

I am trying to remove small holes and objects and use threshold_yen but it is not doing anything at all. Im not getting errors aswell, is the import wrong or am i missing somwthing here

0

There are 0 answers