i have a dataset consists of skin cancer images. i want to remove skin area from those images. To do so,
- first convert images to hsv and split it into h,s,v channels.
- take 4 patches from the corners of the image(skin area) and find the pixel range of skin area.
- in the hsv image if the pixels are in the range which found earlier replace it with 1 and otherwise 0 final output image should be a black and white image. since i am new to python i am not able to figure out where i am doing wrong.please kindly help me.
image_array=[]
for category in CATEGORIES:
path = os.path.join(DATADIR,'train')# create path
for img in os.listdir(path): # iterate over each image
image_array=cv2.imread(os.path.join(path,img),cv2.IMREAD_COLOR)
image_array=cv2.cvtColor(image_array, cv2.COLOR_BGR2RGB)
plt.imshow(image_array)
plt.title('Original image')
plt.show()
break
break
# hsv image array
hsv_image=cv2.cvtColor(image_array, cv2.COLOR_RGB2HSV)
plt.imshow(hsv_image)
#hue image
h_image=[]
h_image =hsv_image.copy() # Make a copy
h_image[:,:,1] = 0
h_image[:,:,2] = 0
plt.imshow(h_image)
#calculating min and max values
htr_patch = Rectangle((180,0), 60, 60, edgecolor='r', facecolor='none')
hbr_patch = Rectangle((180,180), 60, 60, edgecolor='r', facecolor='none')
htl_patch = Rectangle((0,0), 60, 60, edgecolor='r', facecolor='none')
hbl_patch = Rectangle((0,180), 60, 60, edgecolor='r', facecolor='none')
h_min=[]
h_max=[]
h_patches=[htr_patch,hbr_patch,htl_patch,hbl_patch]
for h in h_patches:
print(h)
coord = Rectangle.get_bbox(h).get_points()
h=h_image[int(coord[0][1]):int(coord[1][1]),int(coord[0][0]):int(coord[1][0])]
min_val=np.min(h)
print("min val=",min_val)
h_min.append(min_val)
max_val=np.max(h)
print("max val=",max_val)
h_max.append(max_val)
plt.imshow(h)
plt.show()
print("min vals",h_min)
print("max vals",h_max)
#binary image
binary_image=cv2.inRange(h_image,h_min_,h_max_)