Exemplo n.º 1
0
from segmentation import process_image
from aggregate import aggregateData
import skimage.io
import matplotlib.pyplot as plt

image = skimage.io.imread(
    "Data/Unearthed Cape Town/De Beers Particle Size Challenge/ParticleSegmentationImages/original3.png"
)
truth = skimage.io.imread(
    "Data/Unearthed Cape Town/De Beers Particle Size Challenge/ParticleSegmentationImages/original3.png"
)

# trim borders
border_width = 50
truth = truth[:, border_width:-border_width]

image, labelledFeat = process_image(image)
colorData, sizeData = aggregateData(image, labelledFeat)

fig, (ax1, ax2, ax3) = plt.subplots(3, 1, sharex=True, sharey=True, figsize=(30, 10))

ax1.imshow(image, cmap=plt.cm.gray)
ax1.imshow(truth, cmap=plt.cm.gray)
ax1.imshow(labelledFeat, cmap=plt.cm.gray)

ax1.axis("off")
ax2.axis("off")
ax3.axis("off")
Exemplo n.º 2
0
import time
import scipy.ndimage as ndi

DIR = "Data/Unearthed Cape Town/De Beers Particle Size Challenge/Originals"
TRUTHDIR = "Data/Unearthed Cape Town/De Beers Particle Size Challenge/Truth"
for file in os.listdir(DIR):
    if file.endswith(".png"):
        FILEPATH = DIR+"/"+file
        TRUTHPATH = TRUTHDIR+"/truth"+file[-5:]
        print(FILEPATH)
        image = skimage.io.imread(FILEPATH)
        truth = skimage.io.imread(TRUTHPATH)
        border_width = 150
        image = trim_borders(image,border_width)
        image, labelledFeat, procTime = process_image(image)
        colorData, sizeData, featTime = aggregateData(image,labelledFeat)

        truth = trim_borders(truth, border_width)

        # filter truth image
        truth2 = np.zeros_like(truth)
        truth2[truth < 100] = 1
        truth2[truth > 100] = 0
        truth_particles, truth_features = ndi.label(truth2)

        view = viewer.viewerClass(image, labelledFeat, colorData, sizeData)
        view.view(selectSize=True, sizeValue=200)


image = skimage.io.imread("Data/Unearthed Cape Town/De Beers Particle Size Challenge/Originals/original1.png")
image = trim_borders(image,150)