imregister with rigid transformation

1 view (last 30 days)
Gregory
Gregory on 29 Sep 2014
Commented: Image Analyst on 29 Sep 2014
Hi, I have significant pose variation in a set of images. The images consist of an object against an offwhite background with some variations in intensity value. I wish to align the images, and imregister does a good job of that. However, the 'registered' image now has black triangular areas around the boundary of the image, given the amount of rotation that was necessary to overcome the pose variation. IS there an easy way to return the black triangles to the off-white background or something close? Thanks!

Answers (1)

Image Analyst
Image Analyst on 29 Sep 2014
Just detect black and set those pixels equal to some off white color:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Black is where all color channels are zero.
blackPixels = redChannel == 0 & greenChannel == 0 & blueChannel == 0;
offWhite = [230, 235, 210]; % Whatever color you want.
% Make black pixels the off white color for each color channel, respectively.
redChannel(blackPixels) = offWhite(1);
greenChannel(blackPixels) = offWhite(2);
blueChannel(blackPixels) = offWhite(3);
% Recombine separate color channels into a single, true color RGB image.
rgbImage = cat(3, redChannel, greenChannel, blueChannel);
% Display it
imshow(rgbImage);
  2 Comments
Gregory
Gregory on 29 Sep 2014
Thanks Image Analyst, I am reluctant to do that because part of the object is also black. I am thinking that I will perform a segmentation first and then use imregister on the isolated objects. And then look at the svd of the segmentation instead of the original images (after imregister). Please let me know if you have any other thoughts!
Image Analyst
Image Analyst on 29 Sep 2014
As long as the pure black parts in your image to not touch the edge of the image, you can use imclearborder() to get only the black triangles that touch the border and none of the black regions inside your image. If they do touch the border, you could always set those [0,0,0] pixels to [0,0,1] - not enough to notice but they won't get picked up as black.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!