I have hundreds of PNG images for which I have to generate corresponding B&W images that show the outer outline of the object. The source PNG image has alpha channel, so
OpenCV has a findContours function that does exactly what you want. You will need to set contour retrieval mode to CV_RETR_EXTERNAL. To load your images use the imread function.