Hi,
You can use "rgb2grey" function in MATLAB to convert an image to a black and white image.
For further reference on rgb2grey function use the following link.
For distinguishing for buildings and sky in the image you have to use object detection on the image. For that you have to train a model which could detect buildings and sky in the image and use that model on your image.
For more info you could use the following link.