What is Tiling Effect in MATLAB?
Last Updated :
22 Nov, 2022
MATLAB is a high-performance language that is used for matrix manipulation, performing technical computations, graph plottings, etc. It stands for Matrix Laboratory. With the help of this software, we can provide a tiling effect to an image. It is done by breaking the original image and then allocating the pixels to the new image using loops.
Tiling Effect is dividing an image into grid and showing the grids separately by shifting them in random direction by random amount.
Steps to create Tiling effect on an image:
- Read the image using imread command.
- Create a variable ‘imageWithEffect’ that will store the image with a tiling effect.
- Declare row and column sizes to get tiles of different sizes and also declare tile sizes to create gaps between tiles.
- Iterate through nested while loops in which we’ll set tile sizes and add the original image’s dimensions to the variable ‘imageWithEffect’.
- Close the loops and show the final image.
Matlab
original = imread( 'GeeksforGeeks.jpg' );
imageWithEffect = uint8(zeros(size(original)));
i=1;
j=1;
row=0;
col=0;
m=1;
n=1;
rowSize = 20;
colSize = 35;
tileRowSize = 3;
tileColSize = 5;
while (i < size(original,1))
while ( (m+i+row) < size(original,1) && (n+j+col) < size(original,2) )
imageWithEffect(m+i:m+i+row,n+j:n+j+col,:) = original(i:i+row,j:j+col,:);
m=ceil(rand(1)*tileRowSize);
n=ceil(rand(1)*tileColSize);
col=ceil(rand(1)*colSize);
row=ceil(rand(1)*rowSize);
j=j+col;
end
i = i + row;
j =1;
end
imshow(original), title( 'Original' );
figure,imshow(imageWithEffect), title( 'Image With Tiling Effect' );
|
Output:
Input Image:
Output Image(Image with Tiling Effect):
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...