Achieve image segmentation-generate multiple div segmentation images use the for and two-dimensional arrays to set the background positioning, div two-dimensional array

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.