So i´m learning image processing in python and i came across an exercise on which i'm having strugle to solve. It's given an aerial image:
The objective is to individualize all the roofs in one image leaving the rest of it (background) in a black color. The exercise suggests using the difference between the rgb bands and then apply a threshold method that uses the greater distance correspondent point from the line joining the first nonzero frequency index and the significant peak of the histogram (maximum distance method).
The exercise also shows an example of what should be the final result:
Here's what i've tried so far:
from imageio import imread
import numpy as np
Imagem2 = imread("ik02.tif")
r2 = Imagem2[:,:,0]
g2 = Imagem2[:,:,1]
b2 = Imagem2[:,:,2]
r_b = r2-b2
rbh, rb = np.histogram(r_b, bins=256, range=(0, 256))
From the observation of the histogram it is possible to distinguish two dark peaks, approximately 0 for roads and 3 for houses? Maybe "cut" the values below and up from the house?
(Red band - Blue band) operation gives me a good result to procceed with, i just don't know how to individualize the houses. Here´s the result:
Appreciate any help!