Main Content

implay

View 2-D medical image series in Video Viewer app

Since R2023a

Description

Medical Imaging Toolbox™ extends the functionality of the implay (Image Processing Toolbox™) function to display a medicalImage object. The function uses the medicalImage properties to set the frame rate of the Video Viewer app. If you do not have Medical Imaging Toolbox installed, see Video Viewer.

Medical Image Object

implay(medImage) opens the Video Viewer app and loads the image series in the medicalImage object medImage. The app displays the first frame of the image series. Click the Play button to view the image series as a video. The app automatically sets the frame rate using the FrameTime property of medImage.

example

Nonmedical Image Formats

implay(filename) opens the Video Viewer app and loads the content of the Audio Video Interleaved (AVI) file with filename filename.

implay(I) opens the Video Viewer app and displays the first frame in the multiframe image sequence I, specified as a numeric array or MATLAB® movie structure.

Additional Options

implay(___,fps) specifies the frame rate fps in frames per second, in addition to any input argument from a previous syntax.

Examples

collapse all

Specify the filename of an echocardiogram ultrasound series. The DICOM file is attached to this example as a supporting file.

filename = "heartUltrasoundSequenceVideo.dcm";

Read the metadata and image data from the file by creating a medicalImage object. The FrameTime property indicates that each frame has a duration of 33.333 milliseconds. The NumFrames property indicates that the series has a total of 116 image frames.

medImg = medicalImage(filename)
medImg = 
  medicalImage with properties:

          Pixels: [600×800×116×3 uint8]
        Colormap: []
    SpatialUnits: "unknown"
       FrameTime: 33.3330
       NumFrames: 116
    PixelSpacing: [1 1]
        Modality: 'US'
    WindowCenter: []
     WindowWidth: []

View the ultrasound series as a video by using the Video Viewer app. By default, the app plays the video at the frame rate specified by the FrameTime property value.

implay(medImg)

Input Arguments

collapse all

Medical image, specified as a medicalImage object. The video plays at the frame rate specified by the FrameTime property value of medImage. If the FrameTime property is empty, the default frame rate is 20 fps.

Name of an Audio Video Interleaved (AVI) file, specified as a string scalar or character vector. The video plays at the frame rate specified by the file metadata. If the file metadata does not specify a frame rate, the default frame rate is 20 fps.

Data Types: char | string

Multiframe image sequence, specified as one of these values:

  • An m-by-n-by-k numeric or logical array representing a grayscale or binary image sequence, respectively, of k frames.

  • An m-by-n-by-1-by-k numeric or logical array representing a grayscale or binary image sequence, respectively, of k frames.

  • An m-by-n-by-3-by-k numeric array representing a truecolor (RGB) image sequence of k frames.

  • A MATLAB movie structure. For more information, see immovie.

For numeric data, the preferred data type of I is uint8. The actual data type used to display pixels may differ from the source data type.

The default frame rate is 20 frames per second. To change the frame rate, specify the second input argument, fps.

Frame rate in frames per second, specified as a positive numeric scalar. If the input is a medicalImage object or AVI filename, with a frame rate specified by the FrameTime property or AVI file metadata, respectively, implay uses the specified frame rate. If the frame rate is not specified by the FrameTime property or file metadata, or if the input is a numeric array, the default value is 20 frames per second.

Data Types: single | double

Version History

Introduced in R2023a