Skip to content

Instantly share code, notes, and snippets.

View jeanpat's full-sized avatar

Pommier jeanpat

View GitHub Profile
@jeanpat
jeanpat / extractParticles.ipynb
Created January 29, 2014 14:13
Image segmentation can be performed by an image labelling process. Once segmented, it could necessary to isolate in independant images the labelled regions. Think of chromosomes in a metaphase image, if resolving chromosomes overlapps or karyotyping must be performed. The following script takes "two images", (in fact two small numpy arrays:img i…
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jeanpat
jeanpat / extractParticles.py
Last active August 29, 2015 13:56
A python function relying on scipy.ndimage to extract region of interest in an image or in a stack of images with a a label image, spurious pixels are removed.
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)
@jeanpat
jeanpat / chromosomes extraction from mfish image.ipynb
Last active August 29, 2015 13:56
This ipython notebook shows how to extract, with scipy.ndimage, chromosomes from a set of mfish images.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jeanpat
jeanpat / resizeImages.py
Created February 21, 2014 15:20
Given a list of monochrome images or multispectral images (example rgb, or also a z-stack of images) build a list of images of the same size by adding borders.
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)):
@jeanpat
jeanpat / MaximalQuadrilateralFromNecklaces.ipynb
Created April 10, 2014 12:27
Here 4-tuples of points are considered. A necklace is a set of 4-tuples which can be deduced from one to an other one by circular permutations. With four points, when a maximal area quadrilateral is searched it is faster to search it in the set of the six possible necklaces than in the set of the 4!=24 possible permutations of a 4-tuple.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jeanpat
jeanpat / DrawLetters.py
Created May 30, 2014 14:48
Draw letters with Pillow using the verdana true type font
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))
@jeanpat
jeanpat / FromSkeletonToGraph.ipynb
Last active August 29, 2015 14:02
A ipython notebook showing how to convert the skeleton of a binary image into a networkw graph
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jeanpat
jeanpat / SkeletonTo graph.ipynb
Created June 1, 2014 16:48
Ipython notebook: generate some model images (uppercase letters) and build a graph from their skeleton
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jeanpat
jeanpat / Skeleton_to_Graph.ipynb
Last active August 29, 2015 14:02
Converting skeleton to graph. A rough ipython notebook. More explanations here: http://dip4fish.blogspot.fr/2014/05/construct-graph-from-skeleton-image-of.html
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jeanpat
jeanpat / C8Skeleton_to_graph-01.ipynb
Created June 12, 2014 08:19
Converting skeleton to graph. A rough ipython notebook. More explanations here: http://dip4fish.blogspot.fr/2014/05/construct-graph-from-skeleton-image-of.html
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.