How to label regions that they do not have same values?

Question:

I have stacked 5 probability map in a numpy array (a with the shape 256x256x5), that I have stacked them and then I get the argmax of all of them that final output is show by different 5 colors, however, the values correspond to a pixel within an area are not same (values are changing between [0,1]).

max_= np.argmax(a, axis=2)
plt.imshow(max_)
plt.show()

enter image description here

I do not know how to separate each object by value, because pixels inside a region do not have same values. Does someone know how to label this five objects (colored parts and including background)?

Asked By: S.EB

||

Answers:

If I understand the question, you want the maximum probabilities themselves, not the indices of the maximum probabilities. (Small point: if you array really is shape 5 × 256 × 256, then I think you did np.argmanx(a, axis=0) to get that result.)

This will give you the maximum probabilities themselves:

max_prob = np.amax(a, axis=0)

If you want each ‘object’ on its own, you could then do this for each of the regions:

prob_1 = np.zeros((256, 256))
prob_1[max_ == 1] = max_prob[max_ == 1]
prob_1[prob_1 == 0] = np.nan
Answered By: kwinkunks