Reputation: 755
As shown in this image, I want to label the edges of three branches with purple color and filter other area as purely white color (or other background color). I use Laplacian and sober to do image gradient and then use canny method to do edge detection. However, it does not reach my expectation.
import cv2
import numpy as np
from matplotlib import pyplot as plt
if __name__ == '__main__' :
# Read image
im = cv2.imread("crop.jpg")
# Calculation of Laplacian
laplacian = cv2.Laplacian(imCrop,cv2.CV_64F)
edges = cv2.Canny(laplacian,35,35)
Upvotes: 1
Views: 2664
Reputation: 755
I came up with a solution as below,
import cv2
import numpy as np
from matplotlib import pyplot as plt
if __name__ == '__main__' :
# Read image
im = cv2.imread("crop.jpg")
a=np.copy(im)
a[:,:,0]=255
a[:,:,1]=255
a[a>150]=255
plt.imshow(a)
Upvotes: 0
Reputation: 389
Try to improve it to get your goal:
import cv2
image = cv2.imread("test.jpg")
#convert to hsv
i = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
i[: ,:, 0]=0
i[: ,:, 2]=0
#s channel
cv2.imshow("s channel", i)
Upvotes: 1