フィルターのクリア

How can i find out where the centriod is present in a grided image

2 ビュー (過去 30 日間)
Sarmad Paracha
Sarmad Paracha 2019 年 5 月 16 日
回答済み: Sarmad Paracha 2019 年 5 月 21 日
I have taken an image from the camera and generated grids on it. How can i know in which grid my centroid is pesent. I need to generate a variable or a number which i can use further. For example the centroid is in the 3rd box it generates 3 and i can send it to arduino using serial communication for futher action. I hope you get the idea. Can ROI be helpful in this case if yes then how can i use it ?
any help ?

採用された回答

Sarmad Paracha
Sarmad Paracha 2019 年 5 月 21 日
If anyone is looking for the solution you can do this if you have one centroid in the image
If you want to get the grid row and column numbers, you should plot the grid with predefined grid row and column width:
rowWidth = 52; % Grid row width in pixels
colWidth = 53; % Grid column width in pixels
[rows, columns, ~] = size(Image);
for row = 1 : rowWidth : rows
line([1, columns], [row, row], 'Color', 'r');
end
for col = 1 : colWidth : columns
line([col, col], [1, rows], 'Color', 'r');
end
To get the the grid row and column numbers (assuming you have only one centroid):
% Get the row and column of the centroid (in grid units)
centroidGridCol = ceil(stat(1).Centroid(1) / colWidth);
centroidGridRow = ceil(stat(1).Centroid(2) / rowWidth);

その他の回答 (0 件)

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by