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