Displaying images and overlaying regions

Displaying an image

Default display of an Exposure object

The mtv() method of your display is used to display Exposures, MaskedImages and Images from the stack. Assuming that your session includes an Exposure named calexp:

display1.mtv(calexp)

Mask display and manipulation

If the data object passed to mtv() contains masks, these will automatically be overlaid on the image. A layer control icon at the top of the browser window can be used to turn mask layers on and off.

The display1.setMaskPlaneColor() and display1.setMaskTransparency() methods can be used to programmatically change the mask display. display1.setMaskPlaneColor() must be used before the image is displayed, while the transparency may be changed at any time.

display1.setMaskPlaneColor('DETECTED', afwDisplay.GREEN)
display1.setMaskTransparency(30)
display1.mtv(calexp)

Rescale or restretch the image pixels display

You can rescale or restretch the display of the image pixels wit the scale method.

display1.scale('log', -1, 10, 'sigma')
display1.scale('asinh', 'zscale')

These settings are “sticky”, in the sense that they can be commanded before an image is displayed, and they will apply to subsequent image displays on that Display object.

Zooming and panning

Use the pan method with pixel coordinates to center the image at a new location. The zoom method can zoom and pan at the same time.

display1.pan(1064, 890)
display1.zoom(4)
display1.zoom(2, 500, 800)

These settings are also “sticky” – they can be issued before an image is displayed.

Overlay regions

Firefly support for overlaying regions enables symbols and lines to drawn over an image.

When drawing many items it is best to use display1.Buffering to send them to Firefly in one batch. A good example is drawing circles at the source positions.

with display1.Buffering():
    for record in src:
        display1.dot('o', record.getX(), record.getY(), size=20, ctype='orange')

You can draw lines, optionally with symbols. Here is how to draw a square.

display1.line([[100,100], [100,200], [200,200], [200,100], [100,100]], ctype='blue')

Erase the regions while leaving the image and masks displayed.

display1.erase()