review
Image segmentation (segmentation, cut) refers to the process of dividing a digital image into multiple image sub-regions.
There are many important applications in practical scenarios
In generalized image segmentation, traditional methods and deep methods have different definitions for segmentation.
-
Traditional methods: For image region division, the core issues are: inter-regional differences and intra-regional similarities . Essentially a clustering problem
-
Depth method: for pixel-level classification of images, the core problem is: pixel-by-pixel classification , which is essentially a classification problem
In fact, in the deep method, there is a more subdivided problem definition for semantic segmentation
-
Semantic segmentation: separating the foreground from the background
-
Instance segmentation: classify and segment different objects
This course will briefly introduce traditional image segmentation algorithms, focusing more on semantic segmentation problems.
Traditional methods of image segmentation
In the era of traditional methods, the pixels of the image are mainly divided based on elementary image features, which is essentially a process of merging a cluster of pixels.
The main ideas include:
-
Threshold method: According to different pixel value levels, different methods are divided. The representative method is the histogram method
-
Marginal method: Region division based on gradient.
-
Area method: Starting from a pixel, the surrounding pixels are continuously merged into a larger area. Representative methods: region growing, watershed algorithm
-
Contour method: set an initial contour, define the function value and optimize it to approximate the real contour of the object.
-
Graph theory method: treat the region as a whole and cut it continuously. Until the cutting does not move (satisfies the threshold).
regional law
region growing algorithm
- Choose a pixel as the center point;
- Expand outward from the seed, and gradually add the points that meet the conditions to the seed set;
- Execute the second step until no new points are added to the set.
watershed algorithm
- Find the minimum gray value pixel point, let the threshold grow from the minimum value
- During the growth process, if the adjacent threshold pixel is not classified, add the pixel value
- The above process until it meets at the boundary, thereby partitioning the pixels
graph theory
Each pixel is regarded as a node, and pixels and pixel connections are regarded as edges.
from skimage import data, segmentation, color
from skimage import graph
from matplotlib import pyplot as plt
img = data.coffee()
plt.imshow(img)
labels1 = segmentation.slic(img, compactness=30, n_segments=400,
start_label=1)
out1 = color.label2rgb(labels1, img, kind='avg', bg_label=0)
g = graph.rag_mean_color(img, labels1, mode='similarity')
labels2 = graph.cut_normalized(labels1, g)
out2 = color.label2rgb(labels2, img, kind='avg', bg_label=0)
fig, ax = plt.subplots(nrows=2, sharex=True, sharey=True, figsize=(6, 8))
ax[0].imshow(out1)
ax[1].imshow(out2)
for a in ax:
a.axis('off')
plt.tight_layout()
principle
However, in this way, the more marginal regions will be segmented separately. ( unbalanced distribution of data )
Therefore, the normalized cut algorithm improves the optimization function and proposes a way to normalize the distance.
Semantic Segmentation with Deep Learning
data set
- coco data set: 200,000 labeled data, 1.5 million object instances, 171 categories
- Human parsing dataset: 25403 images, including 59 categories of background
- cityscapes: 30 categories, 5000 pieces of finely labeled data, 20000 pieces of rough labeled data
- kitty
Evaluation index
-
execution time
-
take up content
-
Accuracy (ACC)