Extract list of non zero pixels of a binary image

i want to extract non-zero pixels into a separate array. and later I want to find covariance matrix, followed by eigen values and vectors to find the direction .
How can I do this using simple itk?
Can I just transform the sitk image into numpy array and do normal coding as we do in python? or are there any specific ways to do it using sitk?

Do you want an array of the image intensities, physical coordinates or indices?

The LabelShapeStatisticsImageFilter::GetIndexes can be used to obtain a list of indexes, then transformed into physical space if needed.

If this is performed in the physical coordinates, then this is done inside the LabelShapeStatisticsImageFilter, where the PrincipleMoments and PrincipleAxes correspond to the Eigen values and vectors respectfully.

Using SimpleITK is normal coding IMHO, and you certainly can convert the image to numpy, and use that interface if you prefer.