Package pyvision :: Package analysis :: Module Montage :: Class ImageMontage
[hide private]
[frames] | no frames]

Class ImageMontage

source code

object --+
         |
        ImageMontage

Displays thumbnails of a list of input images as a single 'montage' image. Supports scrolling if there are more images than "viewports" in the layout.

Instance Methods [hide private]
 
__init__(self, image_list, layout=(2, 4), tile_size=(64, 48), gutter=2, by_row=True, labels='index', keep_aspect=True, highlight_selected=False)
Constructor
source code
 
draw(self, mousePos=None)
Computes the image montage from the source images based on the current image pointer (position in list of images), etc.
source code
 
asImage(self)
If you don't want to use the montage's built-in mouse-click handling by calling the ImageMontage.show() method, then this method will return the montage image computed from the last call to draw().
source code
 
show(self, window='Image Montage', pos=None, delay=0)
Will display the montage image, as well as register the mouse handling callback function so that the user can scroll the montage by clicking the increment/decrement arrows.
source code
 
setSelectHandler(self, handler)
Add a function that will be called when an image is selected.
source code
 
setHighlighted(self, idxs)
If the montage was created with highlight_selected option enabled, then this function will cause a set of tiles in the montage to be highlighted.
source code
 
getHighlighted(self)
Returns the index list of the tiles which were selected/highlighted by the users
source code
 
_checkClickRegion(self, x, y)
internal method to determine the clicked region of the montage.
source code
 
_initDecrementArrow(self)
internal method to compute the list of points that represents the appropriate decrement arrow (leftwards or upwards) depending on the image montage layout.
source code
 
_initIncrementArrow(self)
internal method to compute the list of points that represents the appropriate increment arrow (rightwards or downwards) depending on the image montage layout.
source code
 
_decr(self)
internal method used by _onClick to compute the new imgPtr location after a decrement
source code
 
_incr(self)
internal method used by _onClick to compute the new imgPtr location after an increment
source code
 
_composite(self, img, pos, imgNum)
Internal method to composite the thumbnail of a given image into the correct position, given by (row,col).
source code

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, image_list, layout=(2, 4), tile_size=(64, 48), gutter=2, by_row=True, labels='index', keep_aspect=True, highlight_selected=False)
(Constructor)

source code 

Constructor

Parameters:
  • image_list - A list of pyvision images that you wish to display as a montage.
  • layout - A tuple (rows,cols) that indicates the number of tiles to show in a single montage page, oriented in a grid.
  • tile_size - The size of each thumbnail image to display in the montage.
  • gutter - The width in pixels of the gutter between thumbnails.
  • by_row - If true, the image tiles are placed in row-major order, that is, one row of the montage is filled before moving to the next. If false, then column order is used instead.
  • labels - Used to show a label at the lower left corner of each image in the montage. If this parameter is a list, then it should be the same length as len(image_list) and contain the label to be used for the corresponding image. If labels == 'index', then the image montage will simply display the index of the image in image_list. Set labels to None to suppress labels.
  • keep_aspect - If true the original image aspect ratio will be preserved.
  • highlight_selected - If true, any image tile in the montage which has been clicked will be drawn with a rectangular highlight. This will toggle, such that if an image is clicked a second time, the highlighting will be removed.
Overrides: object.__init__

draw(self, mousePos=None)

source code 

Computes the image montage from the source images based on the current image pointer (position in list of images), etc. This internally constructs the montage, but show() is required for display and mouse-click handling.

show(self, window='Image Montage', pos=None, delay=0)

source code 

Will display the montage image, as well as register the mouse handling callback function so that the user can scroll the montage by clicking the increment/decrement arrows.

Returns:
The key code of the key pressed, if any, that dismissed the window.

setSelectHandler(self, handler)

source code 

Add a function that will be called when an image is selected. The handler function should take an image, the image index, a list of labels, and a dictionary of other info.

setHighlighted(self, idxs)

source code 

If the montage was created with highlight_selected option enabled, then this function will cause a set of tiles in the montage to be highlighted.

Note: Calling this method will erase any previous selections made by the user.

_checkClickRegion(self, x, y)

source code 

internal method to determine the clicked region of the montage.

Returns:
-1 for decrement region, 1 for increment region, and 0 otherwise. If a select handler function was defined (via setSelectHandler), then this function will be called when the user clicks within the region of one of the tiles of the montage. Signature of selectHandler function is f(img, imgNum, dict). As of now, the only key/value pair passed into the dict is "imgLabel":<label>.

_composite(self, img, pos, imgNum)

source code 

Internal method to composite the thumbnail of a given image into the correct position, given by (row,col).

Parameters:
  • img - The image from which a thumbnail will be composited onto the montage
  • pos - A tuple (row,col) for the position in the montage layout
  • imgNum - The image index of the tile being drawn, this helps us display the appropriate label in the lower left corner if self._labels is not None.