How can i get x,y points of squares center ?

6 views (last 30 days)
In this picture
we have 4 squares. I need 4 x and 4 y points(coordinates) of each square center. Can somebody do it? Because I'm a beginner ...
  5 Comments
mplz
mplz on 13 Jul 2018
Edited: mplz on 13 Jul 2018
1_ (192,90)-->it's just an example.
2_ yes, its Pixels.
3_ no,it's not distance.it's x,y coordinates of square center(1 square) and in fact i want 4x and 4y coordinates for those 4 square center.
4_ after(if) solved this problem ,i tell ,what i was looking for.
thank s
Adam Danz
Adam Danz on 13 Jul 2018
Replies to your points...
(3) I understand they are (x,y) coordinates but where is the origin? Where is (0,0)? For example, the coordinate (5,12) is 5 pixels to the right of x=0 and 12 pixels above y=0. In your example, (192, 90) these are also distances from (0,0) but I don't know where (0,0) is in your image.
(4) feel free to follow up with more specific questions but I think the problem is not well defined and that will make it difficult to find a solution.

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 14 Jul 2018
Edited: Image Analyst on 14 Jul 2018
First of all, use a better exposure. Having a brighter image will give you more contrast and less noise. Then you can just use a bottomhat filter, imbothat() to find the locally dark things. Then use bwareafilt() to extract the 4 largest dark things. Then use regionprops to get their centers and average them. Try the attached script. It makes this:
I'm going out for a bit. See if you can finish that while I'm gone. And let me know how it goes and if you're able to start with a properly lit image.
  2 Comments
mplz
mplz on 14 Jul 2018
Edited: mplz on 15 Jul 2018
thanks you very much,you looking great in image analyst.
i think,I have to explain my project now.
in this project we have one paper shooting target and somebody shot with laser gun on shooting target and then matlab calculate his score .but problem is camera location change,so we need to camera calibration because when camera took picture ,this image is distorted and awry and then distance and score are wrong.
calculating score method is by distance between black circle in center of paper and laser bright circle,and when distance is x then score is 10 and when distance is y score is 9 and ....if distance is out of range score is 0.
scores is 10,9,8,7,6,5,4,3,2,1,0 .
those 4 squares was for calibration i thought ,now i think those squares is not valid and right,i don't know ,maybe somebody bring better offer.
Image Analyst
Image Analyst on 15 Jul 2018
See the camera calibration capabilities in the Computer Vision System Toolbox. https://www.mathworks.com/products/computer-vision/features.html#camera-calibration
They're rather extensive and well thought out so it's nothing I can replicate in one or two hundred lines of code.
If I answered your question(s), can you "Accept this answer"? Thanks.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!