You are here : matlabImage Processingimregdemons

imregdemons() - Image Processing

[D,moving_reg]
= imregdemons(moving,fixed) estimates
the displacement field D that aligns the image
to be registered, moving, with the reference
image, fixed. moving and fixed can
be 2-D or 3-D intensity images.The displacement vectors at each pixel location map locations
from the fixed image grid to a corresponding
location in the moving image. moving_reg is
a warped version of the moving image that is
warped according to the displacement field D and
resampled using linear interpolation.[___] = imregdemons(moving,fixed,N) specifies
the number of iterations to be computed. This function does not use
a convergence criterion and therefore is always guaranteed to run
for the specified or default number of iterations. example[gpuarrayD,gpuarrayMoving_reg]
= imregdemons(gpuarrayMoving,gpuarrayFixed,N) performs
the estimation on a GPU. Note:  


The GPU version does not support 3-D input images. example[___] = imregdemons(___,Name,Value,...) registers
the moving image using name-value pairs to control aspects of weight
computation.


Syntax

[D,moving_reg]
= imregdemons(moving,fixed) example[___] = imregdemons(moving,fixed,N)[gpuarrayD,gpuarrayMoving_reg]
= imregdemons(gpuarrayMoving,gpuarrayFixed,N) example[___] = imregdemons(___,Name,Value,...) example


Example

Register Two Images with Local DistortionsOpen This Example
This example shows how to solve a registration problem in which the same hand has been photographed in two different poses. The misalignment of the images varies locally throughout each image. This is therefore a non-rigid registration problem.
Read the two images into the workspace.fixed  = imread('hands1.jpg');
moving = imread('hands2.jpg');
Convert the images to grayscale for processing.fixed  = rgb2gray(fixed);
moving = rgb2gray(moving);
Observe the initial misalignment. Fingers are in different poses. In the second figure, the two images are overlaid over each other to make it easy to see where the images differ. The differences are highlighted in green.figure
imshowpair(fixed,moving,'montage')
figure
imshowpair(fixed,moving)


Correct illumination differences between the moving and fixed images using histogram matching. This is a common pre-processing step.moving = imhistmatch(moving,fixed);
Estimate the transformation needed to bring the two images into alignment.[~,movingReg] = imregdemons(moving,fixed,[500 400 200],...
    'AccumulatedFieldSmoothing',1.3);
Display the results of the registration. In the first figure, the images are overlaid to show the alignment.figure
imshowpair(fixed,movingReg)
figure
imshowpair(fixed,movingReg,'montage')


Register two images with local distortions on a GPU
Perform a nonrigid registration on a GPU.
Read images into the workspace.fixed  = imread('hands1.jpg');
moving = imread('hands2.jpg');
Observe the initial misalignment. (Fingers are in different
positions.)figure
imshowpair(fixed,moving,'montage')
figure
imshowpair(fixed,moving)
Create gpuArrays and convert the images to grayscale.fixedGPU  = gpuArray(fixed);
movingGPU = gpuArray(moving);
 
fixedGPU  = rgb2gray(fixedGPU);
movingGPU = rgb2gray(movingGPU);Use histogram matching to correct illumination differences
between the moving and fixed images. This is a common preprocessing
step.fixedHist = imhist(fixedGPU);
movingGPU = histeq(movingGPU,fixedHist);
Perform the registration.[~,movingReg] = imregdemons(movingGPU,fixedGPU,[500 400 200],'AccumulatedFieldSmoothing',1.3);
Bring the registered image back to the CPU. movingReg = gather(movingReg);View the results.figure
imshowpair(fixed,movingReg)
figure
imshowpair(fixed,movingReg,'montage')


Output / Return Value


Limitations


Alternatives / See Also


Reference