現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
0 投票
How can I plot the major axis and minor axis for an object in an image?
2 件のコメント
Pamela
2012 年 9 月 1 日
I need your held please !!
Image Analyst
2012 年 11 月 10 日
I've just added a section on "How do I create an ellipse" to the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_create_an_ellipse.3F so that might help you.
採用された回答
Walter Roberson
2012 年 8 月 27 日
regionprops() to get the centroid and orientation (angle). After that it becomes straight trig. The axes length is R, compute R*cos(theta), R*sin(theta), and center those displacements on the centroid.
17 件のコメント
i tried this. Can you help me to complete it please??
img_seg=segmentation(image);
a = regionprops(img_seg, 'Orientation', 'MajorAxisLength', 'MinorAxisLength', 'Centroid');
theta = pi*a.Orientation/180;
x=a.MajorAxisLength*cos(theta);
y=a.MinorAxisLength*sin(theta);
Pamela
2012 年 8 月 29 日
How can i excute this with an image (black background and a color region of interest)
Image Analyst
2012 年 9 月 1 日
I think Steve's blog that Teja referred you to spells it out pretty explicitly. Can't you follow that? Do you want something different than that, like lines instead of ellipses?
I tried it but i had this error
??? Error using ==> iptcheckinput Function REGIONPROPS expected its first input, L, to be integer-valued.
Image Analyst
2012 年 9 月 1 日
You must have a very old version of MATLAB. Try labeling your binary image before passing it in, instead of passing in just the binary image:
labeledImage = bwlabel(img_seg);
measurements = regionprops(labeledImage, 'Orientation', 'MajorAxisLength', 'MinorAxisLength', 'Centroid');
Pamela
2012 年 9 月 1 日
thx it works but if i want to draw the major axes and the minor axes and to hide the ellipse, what should i do??
Image Analyst
2012 年 9 月 1 日
編集済み: Image Analyst
2012 年 9 月 1 日
Use the centroid, orientation, and the two lengths and some simple 10th grade trigonometry (see Walter's response) to find the endpoints of the lines and then use line() to draw the major and minor axes. The angle for the minor axes will be the major axis angle + 90 degrees. There are degree versions of sin and cos called sind() and cosd() if you prefer to work in degrees instead of radians. IMPORTANT NOTE: the axes are determined by an elliptical fit so don't expect the endpoints of the axes to exactly hit the boundary of the object.
I tried this code. Can you correct it for me and how can i use this axes and PCA to study the asymmetry of the object.
xfact = s.MajorAxisLength./2*cos(s.Orientation*pi/180);
yfact = s.MajorAxisLength./2*sin(s.Orientation*pi/180);
Major = line(xfact+s.Centroid(1),yfact+s.Centroid(2));
Image Analyst
2012 年 9 月 2 日
Pamela, I can't run your code because I don't have your image or your segmentation function. But common reasons for things being reversed are getting (row, column) confused with (x,y) when it should correspond to (y, x), and/or plotting points on a different axes than the image, where the YDir property is going the opposite way. Recall that the standard for images is for the top line to be 1 and higher line numbers are below that. This is opposite to the convention that you have is you just use plot() to plot some numbers in a brand new axes. However, plot will be correct if you used "hold on" and plotted in the same axes right over the top of your image.
Thank you, It works now. I managed to draw the two axes but now I need to study the asymmetry of the region. Can you tell me how can I use these axes and the PCA to study the asymmetry of the ROI.
Image Analyst
2012 年 9 月 3 日
Can you do something along these lines:
positivePC1Elements = PC1_image >= 0;
negativePC1Elements = PC1_image < 0;
meanPositivePC1 = mean(PC1_image(positivePC1Elements));
meanNegativePC1 = mean(PC1_image(negativePC1Elements));
if abs(meanPositivePC1 - meanNegativePC1) < someTolerance
% They're close
else
% They're different
end
Pamela
2012 年 9 月 3 日
Thank you Image Analyst, Can you explain to me more because I have no idea about PCA. What represents the variables used??
Pamela
2012 年 9 月 7 日
Bonjour Et comment faire pour ajouter 2 axes de plus et pour pouvoir diviser la région en 8 parties en utilisant 4 axes en total??? Je compte sur votre aide pour pouvoir avancer
Image Analyst
2012 年 9 月 7 日
I can't really give you a course in PCA here. Basically they are the major directions of your independent variables, which can be combinations of your actual variables.
Hi! To study the similarity between 2 images we should use these steps???
-Calculate the mean of the input images
-Subtract the mean from the input images to obtain the mean-shifted images
-Calculate the eigenvectors and eigenvalues of the mean-shifted images
-Order the eigenvectors by their corresponding eigenvalues, in decreasing order
-Retain only the eigenvectors with the largest eigenvalues (the principal components)
-Project the mean-shifted images into the eigenspace using the retained eigenvectors
-Calculate the Euclidean distance
It's the same solution to study the asymmetry of the region?? Can this help me??
Thanks
Image Analyst
2012 年 9 月 9 日
Pamela, I haven't heard of that method to determine similarity. Much more common is SSIM ( http://en.wikipedia.org/wiki/SSIM) and friends, or even PSNR. Or you can use image moments: http://en.wikipedia.org/wiki/Image_moment
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Image Arithmetic についてさらに検索
タグ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
