Ask Your Question

imshow can not correctly show a png file

asked 2018-03-22 11:16:17 -0500

when I try to imshow a png image description

it show noting.

But I can use the chrome open the png file and show it.

edit retag flag offensive close merge delete


It shows nothing ? What does it mean? opencv is an image processing library It does not process alpha channel

LBerger gravatar imageLBerger ( 2018-03-22 11:18:47 -0500 )edit

please show your code. most likely, there's something simple missing, like a waitkey().

berak gravatar imageberak ( 2018-03-22 11:28:55 -0500 )edit

Well, your image is transparent. So when you display it, every pixel is either background (black) or black. That's why you don't see anything.

kbarni gravatar imagekbarni ( 2018-03-22 12:33:04 -0500 )edit

So how should I display it. I export a pcb file to pdf, and then I open pdf by office word2016, and then I save this picture to png file, and I can not imshow it .

outwalllife gravatar imageoutwalllife ( 2018-03-23 03:02:38 -0500 )edit

you use word for image manipulation ? lol. that sounds bad.

berak gravatar imageberak ( 2018-03-23 03:24:16 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-03-23 03:22:23 -0500

berak gravatar image

updated 2018-03-23 03:25:09 -0500

unfortunately, given the weird and complicated pipeline you used, when creating this image, ALL information is in the alpha channel (ONLY!).

so, needs a small detour to make it visible:

im = cv2.imread("platine.png", -1) # keep alpha
alpha = im[:,:,3] # extract it
binary = ~alpha   # invert b/w

imho you should avoid anything with alpha in it, it only causes trouble.

you probably should try to change your pipeline, so it saves a single channel image, with black contours on white bg, instead of trying to mend it later like above.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-03-22 11:16:17 -0500

Seen: 3,441 times

Last updated: Mar 23 '18