This notebook cannot be run on its own. It just serves as a helpful information container for another notebook. Copy the content of the cells below into GenesToPhenotypes.ipynb. DO NOT RUN THE CELLS.
The user loops through the images in the dataframe and thresholds each of the images.
Each image is then saved as a TIFF file.
We only use the df_filtered
Data frame.
for index, row in df_filtered.iterrows():
image_id = row['Image']
image = conn.getObject("Image", image_id)
pixels = image.getPrimaryPixels()
image_plane = pixels.getPlane(0, 0, 0)
filtered = scipy.ndimage.median_filter(image_plane, size=3)
threshold = filters.threshold_otsu(filtered)
print('Threshold value is {}'.format(threshold))
predicted = numpy.uint8(filtered > threshold) * 255
name="%s/%s.tif" % (home, image_id)
tifffile.imsave(name, predicted)