Convert Pixel Values Back to Matrix Indices?

I am taking a matrix of 1s and 0s and turning it into a binary image so that I can measure properties of the image using matlab's 'regionprops' function. I am getting the centroid and Major/Minor axis values of the binary image but those are all in terms of number of pixels. Is there a way to convert those values back to indices/matrix notation?

답변 (1개)

Guillaume
Guillaume 2018년 7월 5일

1 개 추천

Hum, a binary image is a matrix of 1s and 0s. There is nothing to do turn one into the other.
regionprops returns its output as (x, y) where x is the column index of your matrix, and y is the row index of your matrix. So all you have to do to convert regionprops output into matrix index is swap the two columns.

댓글 수: 1

The output for regionprops centroid is (x, y) in pixels from my understanding because I am getting decimal values for the centroid. For example, one centroid calculated is (24.21, 32), which is not an integer value? I was just thrown off with decimal outputs, leading me to believe the centroid and Major/Minor AxisLength functions have values of pixels and not indices.

댓글을 달려면 로그인하십시오.

질문:

2018년 7월 5일

댓글:

2018년 7월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by