Open In App

What is Tiling Effect in MATLAB?

Last Updated : 22 Nov, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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:

  1. Read the image using imread command.
  2. Create a variable ‘imageWithEffect’ that will store the image with a tiling effect.
  3. Declare row and column sizes to get tiles of different sizes and also declare tile sizes to create gaps between tiles. 
  4. Iterate through nested while loops in which we’ll set tile sizes and add the original image’s dimensions to the variable ‘imageWithEffect’.
  5. Close the loops and show the final image.

Matlab




% MATLAB code for 
% Read original Image
original = imread('GeeksforGeeks.jpg');
  
% Create a new imageWithEfect variable
imageWithEffect = uint8(zeros(size(original)));
  
i=1;
j=1;
row=0;
col=0;
m=1;
n=1;
  
% Changing the row size and column size 
% value to obtain tiles of different sizes
rowSize = 20;
colSize = 35;
  
% Changing the tile row size and tile column size 
% value to create gaps between tiles
tileRowSize = 3;
tileColSize = 5;
  
  
% Nested While loop to allocate imageWithEffect required tiles
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,:);
          
        % using rand function to vary size of tiles
        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
  
% Showing original image and image with tile effect
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
Previous
Next
Share your thoughts in the comments

Similar Reads