Getting the coordinates of intense non-black pixels

asked 2019-09-18 02:02:22 -0600

Raki gravatar image

updated 2019-09-18 02:03:09 -0600

I have the below image as an output of my prediction function (of a DCNN model) and now I'd like to get the pixel coordinates of the detected entities (most red pixels). Is there a quick way to achieve that? It's a bit tricky because I would like to get the salient red pixels, not the ones that are "kinda red" on top-left corner. That is, the intense red ones only.

prediction_image

I have the image in the following Python format:

array([[[3, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        ...,
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]],

       [[1, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        ...,
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]],

       [[1, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        ...,
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]],

       ...,

       [[0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        ...,
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]],

       [[0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        ...,
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]],

       [[0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        ...,
        [1, 0, 0],
        [1, 0, 0],
        [3, 0, 0]]], dtype=uint8)
edit retag flag offensive close merge delete

Comments

How about thresholding that image and cutting off all pixels below, say, 250? You will have only the real red ones left.

Witek gravatar imageWitek ( 2019-09-18 11:53:36 -0600 )edit