Created
May 29, 2021 10:21
-
-
Save dynamicguy/bbaae329723590cf88ee5b091b63d802 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from skimage import io, color, img_as_float | |
from skimage.feature import corner_peaks, plot_matches | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from skimage import io, img_as_float, color, exposure | |
img = img_as_float(io.imread('./ml/old-front.jpg')) | |
# Isolate paint marks | |
# Put image into LAB colour space | |
image_lab = color.rgb2lab(img) | |
img = exposure.rescale_intensity(img) | |
# Colours of interest | |
color_array = np.array([ | |
[[[255, 255, 0.]]], # Yellow stuff | |
[[[255, 190, 200.]]], # Pink stuff | |
[[[255, 165, 0.]]], # Orange stuff | |
[[[255, 0, 0.]]], # Red stuff | |
]) | |
idx = 2 | |
# Loop through the color array and pick out the colored features | |
distance_color = color.deltaE_ciede2000(color_array[idx], image_lab, kL=2, kC=1, kH=0.5) | |
# Normalise distance | |
distance_color = exposure.rescale_intensity(distance_color) | |
# Mask image | |
image_filtered = img | |
image_filtered[distance_color > 0.5] = 1 | |
# Plot it up | |
print("Filtered to: ", color_array[idx]) | |
f, (ax0, ax1, ax2) = plt.subplots(1, 3, figsize=(20, 10)) | |
ax0.imshow(img) | |
ax1.imshow(distance_color, cmap='gray') | |
ax2.imshow(image_filtered) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment