How to draw a straight across the centroid points of the barcode using best fit points
조회 수: 1 (최근 30일)
이전 댓글 표시
This is the processed image and I can't increase the bwareaopen() as it won't work for my other image.
EDITED: Anyway I'm trying to find the shortest points in the centre points of the barcode, to get the straight line across the centre points in the barcode.
Example: After doing a centroid command, the points in the barcode are near to each other. Therefore, I just wanted to get the shortest points(which is the barcode) and draw a straight line across.
All the points need not be join, best fit points will do.
EDITED: Step 1
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/146504/image.jpeg)
EDITED: Step 2
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/146505/image.jpeg)
EDITED: Step 3
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/146506/image.jpeg)
댓글 수: 0
답변 (2개)
Image Analyst
2012년 1월 17일
Maybe run imclose and filter it to grab the largest blob, then find the largest inscribed rectangle with this:
I haven't tried it so I don't know if it can handle tilted rectangles.
Otherwise, just use the points Chandra finds and call improfile() to get a profile line across the bar code. Then scan the profile to find out where it starts and stops.
댓글 수: 0
Image Analyst
2012년 1월 18일
Kim, because you have two "lines" I think you need to use RANSAC (<http://en.wikipedia.org/wiki/Ransac)>, unless you can filter out the numbers from your image somehow, in which case you can use polyfit.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!