![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/175657/image.png)
I have extracted an image object, now i need to determine the line of symmetry for that object
조회 수: 7 (최근 30일)
이전 댓글 표시
Hi,
I have an object of which there is a symmetrical pattern, i want to plot a line of symmetry and then determine the array co-ordinates of the boundary point of the that line of symmetry. For example consider below:
How could i go about detecting the line of symmetry for the object?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/163363/image.jpeg)
댓글 수: 0
채택된 답변
Image Analyst
2017년 4월 26일
Try the attached test.m file, below this image it creates.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/175657/image.png)
댓글 수: 4
Image Analyst
2017년 4월 26일
The line does not need to be rotated since it already goes through the main axis of the binary image. Like I said, if you don't like the overall binary image, you can get a different, smaller one to try to find just the stripes, and recompute the angles.
추가 답변 (2개)
Walter Roberson
2017년 4월 26일
data = double(YourImage);
dv = data(:);
try_it = @(ang) sum((reshape(fliplr(imrotate(data,ang,'crop')),[],1) - dv).^2)
A = linspace(0,359.9,500);
fitr = arrayfun(try_it, A);
[~,idx] = min(fitr);
best_ang = A(idx);
Note: what you posted was an object in a white frame. The YourImage I indicate above should have that white frame cropped away (e.g., should be the original image.)
The code here will work for grayscale and color both.
What this does is rotates an image by an angle, with cropping, flips it left to right, and finds the euclidean distance between that and the original. The hypothesis being tested is that there is an axis of reflective symmetry running though the center of the image and that it is just necessary to find the correct angle for it.
This will probably not do exactly what you want, in that your hypothesis probably involves an axis of reflective symmetry to does not run through the center of the image. You should be able to extend the technique to two parameters and evaluating at a grid of value pairs.
fmincon() cannot really optimize this, as it is not a continuous problem: small differences in rotation angles lead to the same output.
Image Analyst
2017년 4월 26일
What if you threshold, then use bwconvhull() to get the convex hull of all blobs, then use regionprops to get the centroid and orientation angle?
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!