KittiSeg icon indicating copy to clipboard operation
KittiSeg copied to clipboard

demo.py output formats

Open ezisezis opened this issue 7 years ago • 1 comments

Hey @MarvinTeichmann !

Can you please help me with this simple problem - how can i output a binary mask from the demo.py script? The one it outputs is a thresholded value ('imgname_raw.png'). How can i make it binary within the script?

ezisezis avatar Jul 15 '17 11:07 ezisezis

If the output is a N-d numpy array arr with values within [0., 1.], then you can do something like:

threshold, upper, lower = 0.5, 1, 0
mask = np.where(arr > threshold, upper, lower)

If I understand which portion of the code you're referring to, this translates to:

output_image = output[0][:, 1].reshape(shape[0], shape[1])
threshold, upper, lower = 0.5, 1, 0
mask = np.where(output_image > threshold, upper, lower)

I hope I understood your question correctly.

villanuevab avatar Jul 20 '17 00:07 villanuevab