Reputation: 3640
I am using the MIAS data set of breast cancer mammography pictures. The data is available here: http://peipa.essex.ac.uk/pix/mias/
for example, an image looks like this:
import cv2
import numpy as np
img = cv2.imread("mdb168.pgm",0)
import matplotlib.pyplot as plt
plt.imshow(img, cmap="gray")
I want to remove all artifacts and unnecessary parts of the image.
To do this,I first binarize the image
ret,thresh1 = cv2.threshold(img,0,255,cv2.THRESH_BINARY)
plt.imshow(thresh1, cmap="gray")
use opening
kernel = np.ones((20,20),np.uint8)
opening = cv2.morphologyEx(thresh1, cv2.MORPH_OPEN, kernel)
plt.imshow(opening, cmap="gray")
then erosion
kernel = np.ones((120,120),np.uint8)
erosion = cv2.erode(opening,kernel,iterations = 1)
plt.imshow(erosion, cmap="gray")
then merge this mask with the original image
merged = cv2.bitwise_and(img, img , mask=erosion)
plt.imshow(merged, cmap="gray")
I am now trying to remove the pectoral muscle in the upper left area. In this publication: https://www.ncbi.nlm.nih.gov/pubmed/26742491 they use the exact same data set and do this with `seeded region growing'. However, there is no code provided and I could not find this in opencv.
I could achieve a similar result by doing dilate/erosion etc again, but I'm looking for a more generalizable solution. Also, some of these images do not show a muscle and this should be detected as well.
Upvotes: 3
Views: 4446
Reputation: 5878
I would use the following approach:
Upvotes: 1