How to get the pixel value at centroid point
1 次查看(过去 30 天)
显示 更早的评论
how i get the pixel value at the centroid of image
i did as below
cn = s(1).Centroid;
rc = round(cn);
pixelValue = img(rc(1),rc(2));
but in some cases error is shown as
Index exceeds matrix dimensions.
Error in exe_demo (line 73)
pixelValue = img(rc(1),rc(2))
But the centroid point is plotted correctly. How to get the pixel value at that point without error.
0 个评论
采纳的回答
Walter Roberson
2017-9-20
pixelValue = img(rc(2), rc(1));
The centroid coordinate order is X, Y, but image arrays are in the order Y, X.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Read, Write, and Modify Image 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!