Here is our current pipeline to segment out text and graphic elements from graphic designs:
0- input image
1- Cluster pixels according to color (using k-means)
2- Extract connected components
Here are n=63 different connected components extracted.
3- Construct a graph with n nodes. Add edges according to some hand-defined criteria that includes:
Pairwise distance of nodes
Similarity of stroke width
Similarity in x and y coordinates separately
Whether the nodes surround each other
Color similarity
and a combination of these.
(A piece of code to generate the graph is at the bottom of the page.)
Here is a connectivity matrix:
4- Compute connected components in this graph
5- Classify the resulting larger components according to some criteria to determine text components.
6- Remove text components as follows:
7- To determine graphic elements, follow steps 3, 4, 5 that are tailored for graphic elements this time. Here is an output graphic segmentation:
Here is a piece of code to generate the graph in step 3:
g=false(nCC,nCC);
g=g| colordistfg<0.15 & yiou>0.3 & swthi>0.5 & xgap<n/20 & comp_edge==0 & comp_edge^2==1;
g=g| colordistfg<0.45 & yiou>0.3 & swthi>0.4 & xgap<n/20 & comp_edge==0 & comp_edge^2==1;
g=g| colordistfg<0.15 & yiou>0.0 & swthi>0.6 & xgap<n/40 & comp_edge==0 & comp_edge^2==1;
g=g| colordistfg<0.05 & yiou>0.2 & swthi>0.5 & xgap<n/20 & comp_edge==0 & siblings;
g=g| colordistfg<1.20 & yiou>0.7 & swthi>0.8 & xgap<n/40 & comp_edge==0 & siblings;
g=g| colordistfg<0.55 & siblings & comp_edge==1;
% Each of the following is an nxn matrix:
% colordistfg: color distance
% yiou: intersection over union along y direction
% swthi: histogram intersection of stroke width transform
% xgap: distance along x direction
% comp_edge: wether the two components touch
% siblings: they have a common component that surrounds both
% xgap: distance along x direction
% comp_edge: wether the two components touch
% siblings: they have a common component that surrounds both







No comments:
Post a Comment