필터 지우기
필터 지우기

How to get the pixel value at centroid point

조회 수: 1 (최근 30일)
Elysi Cochin
Elysi Cochin 2017년 9월 20일
답변: Walter Roberson 2017년 9월 20일
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.

채택된 답변

Walter Roberson
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개)

카테고리

Help CenterFile 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!

Translated by