Documentation Center

  • Trial Software
  • Product Updates

imshowpair

Compare differences between images

Syntax

Description

example

h = imshowpair(A,B) creates a visualization of the differences between images A and B. If A and B are different sizes, imshowpair pads the smaller dimensions with zeros on the bottom and right edges so that the two images are the same size. h is a handle to the HG image object created by imshowpair.

example

h = imshowpair(A,RA,B,RB) displays the differences between images A and B, using the spatial referencing information provided in RA and RB. RA and RB are spatial referencing objects.

example

h = imshowpair(___,method) uses the visualization method specified by method.

example

h = imshowpair(___,Name,Value) specifies additional options with one or more Name,Value pair arguments, using any of the previous syntaxes.

Examples

expand all

Display Two Images That Differ by Rotation Offset

Display a pair of grayscale images with two different visualization methods, 'diff' and 'blend'.

Load an image into the workspace. Create a copy with a rotation offset applied.

A = imread('cameraman.tif');
B = imrotate(A,5,'bicubic','crop');

Display the difference of A and B.

imshowpair(A,B,'diff');

Display a blended overlay A and B.

figure;
imshowpair(A,B,'blend','Scaling','joint');

Display Two Spatially Referenced Images with Different Brightness Ranges

Read an image. Create a copy and apply rotation and a brightness adjustment.

A = dicomread('CT-MONO2-16-ankle.dcm');
B = imrotate(A,10,'bicubic','crop');
B = B * 0.2;

In this case, we know that the resolution of images A and B is 0.2mm. Provide this information using two spatial referencing objects.

RA = imref2d(size(A),0.2,0.2);
RB = imref2d(size(B),0.2,0.2);

Display the images with the default method ('falsecolor') and apply brightness scaling independently to each image. Specify the axes that will be the parent of the image object created by imshowpair.

figure;
hAx = axes;
imshowpair(A,RA,B,RB,'Scaling','independent','Parent',hAx);

Input Arguments

expand all

A — Image to be displayedgrayscale image | truecolor image | binary image

Image to be displayed, specified as a grayscale, truecolor, or binary image.

B — Image to be displayedgrayscale image | truecolor image | binary image

Image to be displayed, specified as a grayscale, truecolor, or binary image.

RA — Spatial referencing information about an input imagespatial referencing object

Spatial referencing information about an input image, specified as spatial referencing object, of class imref2d.

RB — Spatial referencing information about an input imagespatial referencing object

Spatial referencing information about an input image, specified as spatial referencing object, of class imref2d.

method — Visualization method to display combined images'falsecolor' (default) | 'blend' | 'diff' | 'montage'

Visualization method to display combined images, specified as one of the text strings in the following table.

MethodDescription
'falsecolor'Creates a composite RGB image showing A and B overlaid in different color bands. Gray regions in the composite image show where the two images have the same intensities. Magenta and green regions show where the intensities are different. This is the default method.
'blend'Overlays A and B using alpha blending.
'diff'Creates a difference image from A and B.
'montage'Places A and B next to each other in the same image.

Example: imshowpair(A,B,'montage') displays A and B next to each other.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'Scaling','joint' scales the intensity values of A and B together as a single data set.

'ColorChannels' — Output color channel for each input image‘green-magenta' (default) | [R G B] | ‘red-cyan'

Output color channel for each input image, specified as one of the following character strings:

[R G B]A three element vector that specifies which image to assign to the red, green, and blue channels. The R, G, and B values must be 1 (for the first input image), 2 (for the second input image), and 0 (for neither image).
'red-cyan'A shortcut for the vector [1 2 2], which is suitable for red/cyan stereo anaglyphs.
'green-magenta'A shortcut for the vector [2 1 2], which is a high contrast option, ideal for people with many kinds of color blindness.

'Parent' — Parent of image object created by imshowpairhandle to an HG axes object

Parent of image object created by imshowpair, specified as a handle to an HG axes that is the parent of the image object created by imshowpair.

'Scaling' — Intensity scaling option'independent' (default) | 'joint' | 'none'

Intensity scaling option, specified as one of the character strings in the following table.

'independent'Scales the intensity values of A and B independently from each other.
'joint'Scales the intensity values in the images jointly as if they were together in the same image. This option is useful when you want to visualize registrations of monomodal images, where one image contains fill values that are outside the dynamic range of the other image.
'none'No additional scaling.

Output Arguments

expand all

h — Image objecthandle to Handle Graphics image object

Image object, returned as a handle to the Handle Graphics image object created by imshowpair.

More About

expand all

Tips

  • Use imfuse to create composite visualizations that you can save to a file. Use imshowpair to display composite visualizations to the screen.

See Also

| | |

Was this topic helpful?