Realigning an image in a series of pictures

1 view (last 30 days)
So I am taking a series of pictures of fluorescent solute moving through a pipe. I would like to realign these pictures of the center of mass stays in the center as it moves through the pipe. Then I will crop theses pictures. I already have codes working to crop/rotate/move through the images. I was just wondering if there is a center of mass function and an easy way to readjust each photo.
Thanks!

Accepted Answer

Image Analyst
Image Analyst on 9 Feb 2015
You have to first make a canvass that is large enough to hold the various images as they shift and wiggle around as they are aligned. So your canvass might have to be as large as three times your image in each dimension. Use regionprops() to find the "WeightedCentroid". Find the distance of that from the center of your canvass. Then find the starting and ending columns to paste down that image so that the weighted centroid is at the center of the canvass.
See my Image Segmentation Tutorial if you need to find out how to find weighted centroid. http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862. For you, you would probably use the entire image if you want the weighted centroid of the whole image. Otherwise use a mask if you want just part of the image, like a circular portion in the middle.
See attached demo for how to paste an image onto another one.
  1 Comment
Sarah Burnett
Sarah Burnett on 9 Feb 2015
I'm having trouble finding the centroid to begin with. I was first using 'centroid' and getting a large struct which I wasn't sure what to do with. Now I am using 'WeightedCentroid' and getting errors. I just want the (x,y) location of the centroid because then I can create and alignment function to use on all my images. Attached is my sample image.
im = im2double(rgb2gray(imread('tester.jpg')));
c = regionprops(im,'WeightedCentroid');
Also, I've used your color detection by hue tutorial for different fluids research. Very helpful!

Sign in to comment.

More Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!