Problem with "imregister" function

29 visualizaciones (últimos 30 días)
Adrian
Adrian el 21 de Ag. de 2013
Comentada: sathiya sankari T.V el 20 de Ag. de 2015
Hello,
I'm trying to use the imregister function to register two pictures. To get some experience with this function I did nothing else than typing in the code I found on http://www.mathworks.de/de/help/images/ref/imregconfig.html (Open: Examples). My code than looked like that:
fixed = imread('foto.jpg');
moving = imrotate(fixed, 5, 'bilinear', 'crop');
imshowpair(fixed, moving,'Scaling','joint');
[optimizer, metric] = imregconfig('monomodal');
movingRegistered = imregister(moving,fixed,'rigid',optimizer, metric);
After that I get the Error: Error using imregister>parseInputs (line 208) Argument 'MovingImage' failed validation with error: All dimensions of the moving image should be greater than 4.
Error in imregister (line 91) parsedInputs = parseInputs(varargin{:});
Please help me. Thank You.
  3 comentarios
Adrian
Adrian el 26 de Sept. de 2013
Editada: Adrian el 26 de Sept. de 2013
both 480 x 640 x 3 (uint8) But already tried 480 x 640
sathiya sankari T.V
sathiya sankari T.V el 20 de Ag. de 2015
how to check the dimension of the image?.In properties it shows the dimension is 225*225.

Iniciar sesión para comentar.

Respuesta aceptada

Alex Taylor
Alex Taylor el 26 de Sept. de 2013
Editada: Alex Taylor el 26 de Sept. de 2013
Because imregister works with volumetric input as well as with planar 2-D images, there is ambiguity with multi-channel 2-D images, like your RGB input image.
To avoid this ambiguity, you need to form a 2-D image from your RGB image prior to calling imregister. One way to do this is to use rgb2gray on your moving and fixed images prior to calling imregister:
fixed = rgb2gray(fixed);
moving = rgb2gray(moving);
You could also use a particular color channel, as ImageAnalyst suggested.
Otherwise, imregister is going to interpret your input imagery as a 3-plane volume. The error message you are getting is telling you that with the default number of PyramidLevels, there aren't enough pixels along the 3rd dimension to form a pyramid.
  2 comentarios
Image Analyst
Image Analyst el 26 de Sept. de 2013
Once you've done the registration with the grayscale version of the image, how do you get and apply the transform to another image (i.e. the RGB image)?
Alex Taylor
Alex Taylor el 26 de Sept. de 2013
If you are using R2013a (and later), then you can use imregtform to obtain the geometric transformation that relates moving to fixed. imregtform uses the exact same algorithm as imregister, but returns a geometric transformation as the LHS argument:
You can then use the function imwarp to apply the geometric transformation to your RGB image. When a 2-D geometric transformation is applied to an N-D volume, imwarp interprets this as a 2-D plane at a time geometric transformation, which is what you want for an RGB image.

Iniciar sesión para comentar.

Más respuestas (2)

Adrian
Adrian el 23 de Ag. de 2013
I still need some help
  1 comentario
Yazan Awwad
Yazan Awwad el 25 de Sept. de 2013
Hi, I am trying to register two images using imregister as well. I get the same error as urs. I was wondering if u were able to figure out how to get rid of this error. Please let me know. Thank you, Yazan

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 25 de Sept. de 2013
Editada: Image Analyst el 25 de Sept. de 2013
It ran for me with no problem, once I changed to the standard demo image cameraman.tif. You obviously have a lot more stuff going on that you didn't show us because the error showed up on line 91 but you didn't post 91 lines of code.
  4 comentarios
Adrian
Adrian el 26 de Sept. de 2013
fixed = imread('foto.jpg');
moving = imrotate(fixed(:,:,1), 5, 'bilinear', 'crop');
imshowpair(fixed(:,:,1), moving,'Scaling','joint');
[optimizer, metric] = imregconfig('monomodal');
movingRegistered = imregister(moving,fixed,'rigid',optimizer, metric);
Error using imregister>validatePyramidLevels (line 338) All dimensions of the fixed and moving images should be greater than or equal to 16 for 'PyramidLevels' 3.
Error in imregister>parseInputs (line 214) validatePyramidLevels(parsedInputs.FixedImage,parsedInputs.MovingImage, parsedInputs.PyramidLevels);
Error in imregister (line 91) parsedInputs = parseInputs(varargin{:});
Adrian
Adrian el 26 de Sept. de 2013
Editada: Adrian el 26 de Sept. de 2013
OK, now i have the solution: seems to be a difference if a picture has the size: 480 x 640 or 480 x 640 x 1 .
Following code works
fixed = imread('foto.jpg');
fixes = fixed(:,:,1)
moving = imrotate(fixed, 5, 'bilinear', 'crop');
imshowpair(fixed, moving,'Scaling','joint');
[optimizer, metric] = imregconfig('monomodal');
movingRegistered = imregister(moving,fixed,'rigid',optimizer, metric);
But still wondering why this is such a difference for matlab in comparison to
fixed = imread('foto.jpg');
moving = imrotate(fixed(:,:,1), 5, 'bilinear', 'crop');
imshowpair(fixed(:,:,1), moving,'Scaling','joint');
[optimizer, metric] = imregconfig('monomodal');
movingRegistered = imregister(moving,fixed,'rigid',optimizer, metric);
Maybe somebody can explain...

Iniciar sesión para comentar.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by