**Tiling effect**

original Image |

Let’s make some random rectangles from the image.

**MATLAB CODE:**

A=imread('tulip2.jpg');

C=uint8(zeros(size(A)));

i=1; j=1;

col=0;

row=0;

m=1;n=1;

%change the rsz and csz value to obtain pieces in different sizes

rsz=15;

csz=36;

%change the tsz_row and tsz_col values to make some gaps between the pieces.

tsz_row=3;

tsz_col=5;

while ( i < size(A,1))

%check whether i is less than size of (A,1)

while(m+i+row < size(A,1)&& n+j+col < size(A,2))

while ( i < size(A,1))

%check whether i is less than size of (A,1)

while(m+i+row < size(A,1)&& n+j+col < size(A,2))

%size of the

**tiles**varies depending upon the random number
C(m+i:m+i+row,n+j:n+j+col,:)=A(i:i+row,j:j+col,:);

m=ceil(rand(1)*tsz_row);

n=ceil(rand(1)*tsz_col);

col=ceil(rand(1)*csz);

row=ceil(rand(1)*rsz);

j=j+col;

end

i=i+row;

j=1;

end

figure,imshow(C);

With small gaps |

With Large gaps |

Subscribe to 'Image processing' to get the complete code.

## 2 comments:

Thank You a lot for this great effort,

I tried to use this code "Tilling effect",

But this error came up in the line of "while" Command:

"usage might be invalid"

I don;t know what is the solution for that.

M.Selim

@M. Selim

Sorry for the inconvenience. Html code was broken. I have corrected the problem. Now, the code will work without any error.

## Enjoyed Reading? Share Your Views