numpy - How to process (stretch) only the signal of a mix of gaussian? -
i have mixture of 2 gaussians use gmm separate. once predict , know data point belong gaussian (0-background, 1-signal), want process signal part only. processing can histogram eq or clipping, on results 1 (signal). please provide example on how might that, given img
original image , pred
prediction gmm.
img = cv2.imread(path, -1) img_flatten = img.flatten().reshape(img.flatten().shape[0],1) gmm = gaussianmixture(n_components=2, covariance_type='full') gmm.fit(img_flatten) pred = gmm.predict(img_flatten)
you can retrieve signal in flat image selecting parts predicted 1
:
signal = img_flatten[pred==1]
i not familiar processing methods want, clipping values exceeding e.g. 0.5 can use:
signal[signal>0.5] = 0.5
finally can reconstruct processed image:
img_flatten[pred==1] = signal processed_img = img_flatten.reshape(img.shape)
edit: spotted cv2 provides histogram equalization method, instead of wrote above, might use processing signal data:
signal = cv2.equalizehist(signal)
Comments
Post a Comment