現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
extraction of corner points in grid image and how to calculate the distance between corner points
2 ビュー (過去 30 日間)
古いコメントを表示
I ma providing the grid image & i want to find the each corner points of box/square in my image and want to calculate the distance between each corner points
採用された回答
Image Analyst
2017 年 12 月 22 日
You can use the sqrt function. So if x and y are 4 element arrays, then do get the diagonal distances, use the appropriate indexes, for example
diagonalDistance1 = sqrt((x(1)-x(3))^2 + (y(1)-y(3))^2);
diagonalDistance2 = sqrt((x(2)-x(4))^2 + (y(2)-y(4))^2);
You forgot to provide your image (so read this), but assuming you have a white square box on a black background, you can use regionprops to find the centroid of the box, then use bwboundaries to find all the (x,y) coordinates of the perimeter. Then use sqrt() to find the distances of every point to the centroid, and use findpeaks() (in the Signal Processing Toolbox) to find the 4 peaks, which should be at the corners.
19 件のコメント
Image Analyst
2017 年 12 月 22 日
See my attached shape recognition demo for how to find corners using findpeaks().
praveen rai
2017 年 12 月 23 日
編集済み: Image Analyst
2017 年 12 月 23 日
really sorry for that
my graph image
Image Analyst
2017 年 12 月 23 日
See how it helps to post the image? Now my answer is totally different.
What I'd do first is to snap another image of a white sheet and divide the images to get rid of the illumination gradient. Or if you can do that, then try to flatten the image with adapthisteq(). Then threshold to find the black lines, then call bwmorph(bw, 'skel', inf) to skeletonize it, then call bwmorph(bw, 'branchpoints') to find the line crossing locations.
If you need diagonal distances, you can use find() and kmeans() to find clusters of x and y points, then you know which points are where and you can get the distances.
My first method will still work but it will get the corners of the white squares while the other method will get the center of the black line crossing points, which is nearby but not the same location.
praveen rai
2017 年 12 月 23 日
earlier I forgot to upload my image
diagonalDistance1 = sqrt((x(1)-x(3))^2 + (y(1)-y(3))^2);
diagonalDistance2 = sqrt((x(2)-x(4))^2 + (y(2)-y(4))^2);
_with above lines can we find diagonals in my image & what about_ *shape_recognition_demo1.m* _is that relavent in my case??_
Image Analyst
2017 年 12 月 23 日
It depends on whether you want to find the center of the black crossing points, or the corner of the white quadrilaterals. If you want the corners of the white quadrilaterals, then the shape recognition demo will work.
praveen rai
2017 年 12 月 23 日
I want the points where black lines r intersecting 'do first is to snap another image of a white sheet and divide the images to get rid of the illumination gradient.' didnt understand this pint which u suggest and flattening the image is different from illumiantion gradient or it is step 2
praveen rai
2017 年 12 月 23 日
- i have to run this demo with my image den apply these thngs*' Then threshold to find the black lines, then call bwmorph(bw, 'skel', inf) to skeletonize it, then call bwmorph(bw, 'branchpoints') to find the line crossing locations.??
Image Analyst
2017 年 12 月 23 日
編集済み: Image Analyst
2017 年 12 月 26 日
I don't understand the question. Did you run the functions as I suggested? It's trivial and I practically gave you the code already, so did you try it?
binaryImage = grayImage < threshold;
binaryImage = bwmorph(binaryImage, 'skel', inf);
endPointsImage = bwmorph(binaryImage, 'branchpoints');
[rows, columns] = find(endPointsImage);
% Find horizontal lines
[lineNumber, lineCenterY] = kmeans(rows, 7);
[columnNumber, lineCenterX] = kmeans(columns, 10);
and so on. Please try it. You're a smart engineer so I'm sure you can do it.
praveen rai
2017 年 12 月 26 日
編集済み: praveen rai
2017 年 12 月 26 日
[lineNumber, lineCenterY] = kmeans(rows);
[columnNumber, lineCenterX] = kmeans(columns);
_for above code error is showing_ *' *at least two input argument is required**
Image Analyst
2017 年 12 月 26 日
When it says something like that you should look in the help. Pass in the number of lines in each direction for k.
praveen rai
2017 年 12 月 28 日
a = imread('Picture 20.jpg');
% Convert the image to gray level image
b= rgb2gray(a);
% smoothing image
Iblur1 = imgaussfilt(b,2);
% % figure,imshow(Iblur1);
% Apply adaptive histogram eqaulization to enahnce the contrast of the
% image
c=adapthisteq(Iblur1);
% Illumination Correction
MN=size(c);
background = imopen(c,strel('rectangle',MN));
I2 = imsubtract(c,background);
I3= imadjust(I2);
% figure,imshow(I3);
% % Convert to binary image
level = graythresh(b);
d=im2bw(I3,level);
bw = bwareaopen(d, 50);
% figure,imshow(bw);
binaryImage =bw<0.5;
binaryImage = bwmorph(binaryImage, 'skel', inf);
se=strel('line',8,1);
BW=imdilate( binaryImage,se);
se1=strel('line',8,90);
BW=imdilate(BW,se1);
% figure,imshow(BW);
% Convert to binary image to gray
uint8Image = uint8(255 *BW);
c=uint8Image;
figure,imshow(c);
bw3 = bwmorph(c, 'shrink',Inf);
figure,imshow(bw3);
c = detectHarrisFeatures(c);
plot(c);
endPointsImage = bwmorph(BW, 'branchpoints');
[rows, columns] = find(endPointsImage);
% Find horizontal lines
[lineNumber, lineCenterY] = kmeans(:,1);
[columnNumber, lineCenterX] = kmeans(1,:);
_i have applied this code but didnt find the corners and there respective (x,y) locations_
Image Analyst
2017 年 12 月 28 日
Look how you've called kmeans(), then compare to how I showed you and how it shows you in the help. Why do you think you're supposed to pass in colon and one to kmeans()???
praveen rai
2017 年 12 月 28 日
ya i have seen in help wrongly i have pasted this can u explain y we r finding endpointsImage and horizontal lines and is there any method like diffrentiating the horizontal and vertical lines and by doing that corner ponts will get am just asking m not sure about that?!
Image Analyst
2017 年 12 月 28 日
endpoints just gets the ends of the line. If you were to use find() on the entire image, then you'd get a bunch of points along the lines that would confuse the kmeans() in each direction.
praveen rai
2017 年 12 月 28 日
what is d purpose of finding end points and horizontal lines i mean to say i need d corners points and there respective location(x,y)
praveen rai
2017 年 12 月 28 日
is there any function in matlab like circle detector to detect square and find the corner?
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Image Segmentation and Analysis についてさらに検索
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)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)