imregister with rigid transformation
1 view (last 30 days)
Show older comments
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!
0 Comments
Answers (1)
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
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.
See Also
Categories
Find more on Geometric Transformation and Image Registration in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!