Achieve image segmentation-generate multiple div segmentation images use the for and two-dimensional arrays to set the background positioning, div two-dimensional array
<! DOCTYPE html>
<Html>
<Head lang = "en">
<Meta charset = "UTF-8">
<Title> </title>
<Style type = "text/css">
# Box {width: 832px; height: 832px; margin: 0 auto; border: 1px solid red ;}
. Col {width: 50px; height: 50px; border: 1px solid # fff; float: left; background: url(xin.jpg) no-repeat ;}
</Style>
</Head>
<Body>
<Div id = "box"> </div>
</Body>
</Html>
<Script type = "text/javascript">
Var box = document. getElementById ("box ");
Var rowDiv = [];
Var tArray = new Array ();
For (var I = 0; I <16; I ++)
{
TArray [I] = new Array ();
For (var j = 0; j <16; j ++)
{
RowDiv [j] = document. createElement ("div ");
Box. appendChild (rowDiv [j]);
RowDiv [j]. className = "col ";
TArray [I] [j] = rowDiv [j];
Var l =-(j * 50) + "px ";
Var T =-(I * 50) + "px ";
TArray [I] [j]. style. backgroundPositionX = l;
TArray [I] [j]. style. backgroundPositionY = T;
}
}
</Script>
How can we achieve the following split line effect in html? (Figure) answer
This should not be a split line.
If there are two split lines, set the property display: inline-block.
Example:
<Div style = "width: 100%; text-align: center"> // set center
<Hr style = "width: 20%; display: inline-block"/> text inserted in the middle </Div>
Use matlab to divide an image into 10 × 10 small images.
Upstairs, take it for granted.
Clc
Clear
Src_path = 'C: \ 1.jpg '; % original image path
Dst_path = 'C: \ pic_div \ '; % Save the path after splitting the image
Mkdir (dst_path); % indicates that the path does not exist.
A = imread (src_path); % read original image
[M, n, l] = size (A); % get size
For I = 1:10
For j = 1:10
M_start = 1 + (I-1) * fix (m/10 );
M_end = I * fix (m/10 );
N_start = 1 + (J-1) * fix (n/10 );
N_end = j * fix (n/10 );
AA = A (m_start: m_end, n_start: n_end, :); % read each part into the matrix
Imwrite (AA, [dst_path num2str (I) '-'num2str (j) '.jpg'], 'jpg '); % save each image
End
End
The above code has been verified