Package bar :: Module base :: Class barTracedSlideRenderer
[hide private]
[frames] | no frames]

Class barTracedSlideRenderer


barTracedSlide class extension with method necessary to render CAF slide.

Nested Classes [hide private]
Instance Methods [hide private]
(float, float)
__generateLabelLocation(self, path)
Generate best label localtion for given path representation.
(float, float)
getSlideMassCenter(self)
Calculate mass center of the slide basing on grayscale slide representation.
barTracedSlideRenderer
getMask(self, maskColor='#000000')
Change colour of every structure in the slide to given colour.
barTracedSlide
generateLabels(self, skipLabels=[])
Assign text label for each path in the slide and place it in the center (according to maximal value of distance transform) of the path.
PIL.Image.Image
renderStructureList(self, structureNameList)
Render image of requested structures.
barTracedSlideRenderer
getStructuresSubset(self, structureNameList)
Returns: slide containing only requested structures
PIL.Image.Image
renderPath(self, pathObject)
Render the path image.
barPretracedSlideRenderer
contourize(self)
Convert given CAF slide into contour slide by removing fill from paths and assigning them contours.

Inherited from barTracedSlide: __add__, __delitem__, __getitem__, __init__, __len__, __setitem__, addPath, addStructures, affineTransform, findDuplicatedRegions, getXMLelement, has_key, items, keys, recolor, values

Inherited from barTracedSlide (private): _getPaths, _getStructures

Inherited from barSlideRenderer: renderSlide

Inherited from barVectorSlide: Show, addLabel, alignToRefMatrix, deleteLabelByCaption, deleteLabelByID, getCommentLabels, getLabelByName, getRegularLabels, getSpotLabels, renameLabelByCaption, retypeLabelByCaption, srs2svg, svg2srs, updateMetadata

Inherited from barObject: __str__, getElementById, writeXMLtoFile

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Class Methods [hide private]

Inherited from barTracedSlide: fromXML

Static Methods [hide private]

Inherited from barObject (private): _getAttributesDict

Instance Variables [hide private]

Inherited from barVectorSlide: slideNumber, slideTemplate

Inherited from barVectorSlide (private): _labels, _metadata

Properties [hide private]

Inherited from barTracedSlide: crispEdges, pathIndex, paths, structures, svgDocument

Inherited from barSlideRenderer: bitmapSize, size

Inherited from barVectorSlide: labelIndex, labels, metadata

Inherited from object: __class__

Method Details [hide private]

__generateLabelLocation(self, path)

 

Generate best label localtion for given path representation. The optimal position of the label is determined using maximum value of distance transform.

Parameters:
  • path (barPath) - path for which best label location is determined
Returns: (float, float)
optimal coordinates (x, y) of the label in SVG coords

getSlideMassCenter(self)

 

Calculate mass center of the slide basing on grayscale slide representation.

Returns: (float, float)
coordinates (x, y) of the mass center in SVG coords

getMask(self, maskColor='#000000')

 

Change colour of every structure in the slide to given colour.

Parameters:
  • maskColor (str) - colour in hexadecimal format
Returns: barTracedSlideRenderer
self

generateLabels(self, skipLabels=[])

 

Assign text label for each path in the slide and place it in the center (according to maximal value of distance transform) of the path.

All existing regular labels are erased while comment labels and spot labels remains.

Parameters:
  • skipLabels ([str, ...]) - names of structures which labels are preserved
Returns: barTracedSlide
self

renderStructureList(self, structureNameList)

 

Render image of requested structures. At least one of the structures has to be defined in the slide or blank white image will be returned.

Structures are recognized by names of barStructure

Workflow:

  1. Get empty slide using template from existing slide.
  2. Copy desired structures into new slide leaving other structurees
  3. Render temporary slide and return generated image.
Parameters:
  • structureNameList ([str, ...]) - names of structures to be rendered
Returns: PIL.Image.Image
rendered image

getStructuresSubset(self, structureNameList)

 
Parameters:
  • structureNameList ([str, ...]) - structures to be included in the returned slide
Returns: barTracedSlideRenderer
slide containing only requested structures

renderPath(self, pathObject)

 

Render the path image.

Returned image has two colors: white for background, black for foreground.

Parameters:
  • pathObject (barPath) - path representation
Returns: PIL.Image.Image
rendered image

contourize(self)

 

Convert given CAF slide into contour slide by removing fill from paths and assigning them contours.

Returns: barPretracedSlideRenderer
contour slide based on the CAF slide