Matlab to achieve the cutting of the image of the computer vision

Source: Internet
Author: User

In some programs because the image is too large, we often need to cut the image into a few relatively small patterns after the relevant processing.

Img=imread (' sssd.png ');
Imgsize=size (IMG)
subimg_width=600;
subimg_height=1000;
Num_width_spilt=ceil (imgsize (1)/subimg_width);
Num_height_spilt=ceil (Imgsize (2)/subimg_height);
num=num_width_spilt*num_height_spilt;
For i=1:num_width_spilt for
   j=1:num_height_spilt
   if (i*subimg_width<=imgsize (1))
       Width=subimg_ width;
   else
       width=imgsize (1)-(i-1) *subimg_width;
   End
   if (J*subimg_height<=imgsize (2))
       height=subimg_height;
   Else
       height=imgsize (2)-(j-1) *subimg_height;
   End
    Subimg=zeros (width,height);

    For Ii=1:width
    to Jj=1:height
    for Kk=1:3 subimg (II,JJ,KK) =img ((i-1) *subimg_width+ii
   , (j-1) *subimg_ HEIGHT+JJ,KK);
    End
    -end
 
 
  subimg=uint8 (subimg);
    eval ([' Imwrite (subimg, ' subimg ' Num2str (i-1) *num_width_spilt+j) '. bmp ', ' bmp ')
   ; End End

    
The following image is segmented to get four small graphs



Four small figures obtained:

The first one:


Second One


The third one:


Picture Four


Related Article

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.