This question relates to somewhat practice and experienced based process. I have an Mat binary image which consist of simple white color polygons in a black background. Actu
cv::Mat inputImage = cv::imread("input.png", CV_LOAD_IMAGE_GRAYSCALE);
// find non-zero point coordinates
cv::Mat nonZeroCoordinates;
cv::findNonZero(inputImage, nonZeroCoordinates);
Then you can save the nonZeroCoordinates matrix into your file to use.
If you want to create a same image using these coordinates, you can do like this:
std::vector > points;
points.push_back(nonZeroCoordinates);
cv::Mat output = cv::Mat::zeros(inputImage.size(), CV_8UC1);
cv::fillPoly(output, points, cv::Scalar(255));
Hope it helps!