Main Content

getAxesHandles

Get handles to axes in Orthoslice Viewer

Description

[hXY hYZ hXZ] = getAxesHandles(s) returns the axes containing each of the views of the image volume in the orthosliceViewer object s.

example

Examples

collapse all

Load MRI data and view it in the Orthoslice Viewer.

load(fullfile(toolboxdir('images'),'imdata','BrainMRILabeled','images','vol_001.mat'));
s = orthosliceViewer(vol);

Get the handle of the axes that contains the slice.

[hXYAxes, hYZAxes, hXZAxes] = getAxesHandles(s);

Turn off crosshair for better visibility.

set(s,'CrosshairEnable','off');

Specify the name of the GIF file.

filename = 'animatedYZSlice.gif';

Create an array of slice numbers in the required direction. Consider the YZ direction.

sliceNums = 1:240;

Loop through and create an image at the specified slice position.

for idx = sliceNums
    % Update X slice number to get YZ Slice.
    s.SliceNumbers(1) = idx;
  
    % Use getframe to capture image.
    I = getframe(hYZAxes);
    [indI,cm] = rgb2ind(I.cdata,256);
  
    % Write frame to the GIF File.
    if idx == 1
        imwrite(indI,cm,filename,'gif','Loopcount',inf,'DelayTime',0.05);
    else
        imwrite(indI,cm,filename,'gif','WriteMode','append','DelayTime',0.05);
    end
end

View the animated GIF.

Input Arguments

collapse all

Orthoslice Viewer, specified as an orthosliceViewer object.

Output Arguments

collapse all

Axes in Orthoslice Viewer, returned as a 1-by-3 vector of Axes objects.

Version History

Introduced in R2019b