This is a continuation of my older question.
Given non-rectangular region, how do I enumerate all pixels from it and arrange them as a single vector? Order doesn't matter (though should be deterministic). Is there any fast way (or at least standard function) or my best approach is iterating over pixels in the image and picking up only those from ROI?
Additional plus if it is possible to restore region data from that vector later.