이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
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().
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!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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 (한국어)