This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Thu Apr 7 15:19:19 2011 | |
@author: Jean-Patrick Pommier | |
http://www.dip4fish.blogspot.com | |
""" | |
from __future__ import division | |
import numpy as np | |
from scipy import ndimage as nd |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def extractParticles(greyIm, LabIm): | |
locations = nd.find_objects(LabIm) | |
i=1 | |
extracted_images=[] | |
for loc in locations: | |
lab_image = np.copy(LabIm[loc]) | |
grey_image = np.copy(greyIm[loc]) | |
lab_image[lab_image<>i]=0 | |
grey_image[lab_image <>i]=0 | |
extracted_images.append(grey_image) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ResizeImages(ImList): | |
'''Find the largest width and height of images belonging to a list. | |
Return a list of images of same width/height | |
''' | |
maxwidth=0 | |
maxheight=0 | |
if len(np.shape(ImList[0]))==3: | |
components = np.shape(ImList[0])[2] | |
imtype = ImList[0].dtype | |
for i in range(len(ImList)): |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image, ImageDraw, ImageFont | |
import mahotas as mh | |
def makeLetterImage(character, size): | |
image = Image.new("RGBA", (600,150), (255,255,255)) | |
draw = ImageDraw.Draw(image) | |
font = ImageFont.truetype("verdana.ttf", size) | |
draw.text((5, 0), character, (0,0,0), font=font) | |
img_resized = np.array(image.resize((300,75), Image.ANTIALIAS)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mahotas as mh | |
import networkx as nx | |
import numpy as np | |
def C8skeleton_to_graph(skeletonC8): | |
#images processing: extraction of branchedpoints, end-points, edges | |
ep = endPoints(skeletonC8) | |
bp = branchedPoints(skeletonC8, showSE = False) | |
## Label branched-points | |
l_bp,_ = mh.label(bp) |