Centering Multiple circular images

I have multiple images of circular EHL contacts. I need to track the color change of each location within the contact. This is difficult as the contact moves slightly in the different images.
I have tried using the following code to center the images
EHL_image = imread('filename.bmp');
bwimage = rgb2gray(EHL_image);
bwimage(1:460,:) = 0;
BW = im2bw(bwimage,.4);
BWout = imfill(BW,'holes');
[Center, Rad, metric] = imfindcircles(BWout,[100 150],'Method','twostage');
After this process, matlab produces a post-processed image and a predicted circle as seen in the figure "Post_process." I cut the upper portion of the image off as I have found removing the distortion caused by the wake improves imfindcircles accuracy. As seen in the image Post process, the imfindcircles function does not center the circle over the contact well and it greatly varies from image to image.
I need some way to create some type of reference point within the contact such that I can associate the RGB values at different pixel locations with the same location within the contact. This is difficult as all parts of the contact undergo color change as the speed is increased between images.
I have attached two original images of the EHL contact at different speeds. Any creative ideas would be greatly appreciated.

 採用された回答

Jim Riggs
Jim Riggs 2018 年 2 月 14 日

0 投票

Here is a thought.
The images appear to have some significant circular waves emanating from the (presumed) center. I would use this periodic information to locate the center. For example, define two opposing vectors from some reference point near the center, one vector points left and the other points right. Compute the intensity of the image along each vector and plot vs distance from the reference point. Adjust the point left/right position until the periodic behaviors overlap. Now add a third vector pointing down. Adjust the up/down position until the periodic behavior of all three overlap. This should allow you to locate a center reference without using the top half of the image.

5 件のコメント

morri295
morri295 2018 年 2 月 16 日
This is a good idea. It is simply hard to implement because of the variation between images. For example, consider the two plots below. Each one is the R-channel value at a fixed vertical coordinate as you move horizontally across the image.
My process was to give an approximate center location and then observe the number of peaks that appear as I move out to the left and right, respectively. Eventually, I began ignoring the area within the circular contact area since this can be subject to significant noise. I would therefore start numbering peaks as they began appearing then calculate the center of the contact by averaging the x location of the first peak on the right with the x location of the first peak on the left. My issue is trying to correctly number the peaks as I move in either direction.
Using the findpeaks function I can get good results the majority of the time, however, there is undoubtedly a few images where it incorrectly associates a peak on the left with another on the right and throws off the center point prediction.
So if I try to use the first peak that appears, I will have problems because of the inconsistent nature of the image within the contact. If I move to far away the signal greatly decreases and I can't distinguish between noise and signal. Ideally I would use the peak labeled 2 in the attached image but it is difficult to find this peak location in the signal.
Jim Riggs
Jim Riggs 2018 年 2 月 16 日
編集済み: Jim Riggs 2018 年 2 月 16 日
It is clear that the amplitude is attenuating with distance. You should choose a reference point somewhere near the middle and then fold the plot from the reference point, and compare the left and right side. It looks like you will get a "best fit" with the appropriate association of peaks, i.e. line up one peak from the left with one from the right, then try shifting the alignment by one peak and see if the fit is better or worse, etc.
morri295
morri295 2018 年 2 月 16 日
Again, that is a good idea. I am having difficult thinking about how to automate that process. Intuitively, you can look at the plot and see where the centerline must lie but the question is how to have the code do that process for you.
Jim Riggs
Jim Riggs 2018 年 2 月 16 日
Signal processing is not my strong point. I notice that the signal processing toolbox has a function "alignsignals" to align 2 signals by delaying one of them. There is also "xcorr" which computes the correlation and the lag between two similar signals.
Jim Riggs
Jim Riggs 2018 年 2 月 17 日
編集済み: Jim Riggs 2018 年 2 月 17 日
How about this for a brute-force algorithm:
Select one of the well-defined peaks. Establish a window centered on this peak that is approximately +/- 1/2 the period. Now rotate the vector by a small amount and locate the peak inside the search window, and re-center the window. Trace this peak around 180 degrees. Now you have the distance to the same wave peak from 0 to 180 degrees.
It occurs to me that using this method, you would improve the vertical estimate by using more than 180 degrees of the image.

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2018 年 2 月 16 日
編集済み: Image Analyst 2018 年 2 月 17 日

0 投票

Try the attached script. It finds the circular region, finds the centroid of the region, finds the mean R, G, and B intensities in the circular mask region, and returns all the pixel values in the mask for each color channel.
You'll see:
The diameter = 268.39 pixels.
Mean Red Intensity = 123.18
Mean Green Intensity = 75.18
Mean Blue Intensity = 176.13
The Centroid is at x=445.903224, y=507.938276.
If you want to compare the very same pixels in different images (which, if analyzed separately might have slightly differently shaped masks) then you can just compute the mask once, and translate it, with imtranslate(), over each image to the centroid of that particular image. That way the mask is the same shape for all images. Though I still don't know exactly how you want to compare the colors: if it's the overall mean (seems okay), or if you want to somehow compare the R, G, and B values of each of the 56574 pixels in the mask (seems weird to me).
Does this work for you?

2 件のコメント

morri295
morri295 2018 年 2 月 19 日
Thank you for your response and corresponding script. I attempted a similar approach initially but was not able to consistently get a good central location prediction across the various images.
Unfortunately, I must be running an older version of Matlab because the bwareafilt function in your script is not found in my version (R2013a). I was unable to see if your script did a better job than my initial attempt.
Image Analyst
Image Analyst 2018 年 2 月 19 日
You can use bwareaopen() instead of bwareafilt() in many cases.

サインインしてコメントする。

質問済み:

2018 年 2 月 14 日

コメント済み:

2018 年 2 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by