# IMAGE PROCESSING

" Two roads diverged in a wood, and I,
I took the one less traveled by,
And that has made all the difference "-Robert Frost

### Cone effect in MATLAB

The image shrinks towards the center, forming a cone effect. Here, I first found the mid point of the image, since the image expands from the center. Then the angle and the radius of the points are found by converting into polar co-ordinates from Cartesian.  The square root (radius * K) is obtained, where K  can be changed to make the image size differ.
Again convert from polar to Cartesian and display the final image.
For more fun, try this effect with your own photography image .

MATLAB CODE:

B=uint8(zeros(size(A)));
figure,imshow(A);

%FIND THE MID VALUES
midx=ceil((size(A,1)+1)/2);
midy=ceil((size(A,2)+1)/2);

%CHANGE THE VALUE OF 'K'
K=180;
x2=zeros([size(A,1) size(A,2)]);
y2=zeros([size(A,1) size(A,2)]);

%COMPUTATION TO GET CONE EFFECT
for i=1:size(A,1)
x=i-midx;
for j=1:size(A,2)
[theta,rho]=cart2pol(x,j-midy);
sqtrho=sqrt(rho*K);
[l,m]=pol2cart(theta,sqtrho);
x2(i,j)=ceil(l)+midx;
y2(i,j)=ceil(m)+midy;
end
end

% IF THE ARRAY CONTAINS VALUES LESS THAN 1 REPLACE IT WITH 1 AND
% IF GREATER THAN 1 REPLACE WITH SIZE OF THE ARRAY
x2(x2<1)=1;
x2(x2>size(A,1))=size(A,1);

y2(y2<1)=1;
y2(y2>size(A,2))=size(A,2);

for i=1:size(A,1)
for j=1:size(A,2)
B(i,j,:)=A(x2(i,j),y2(i,j),:);
end
end

figure,   imshow(B);

 K=100
 K=180

SEE ALSO : Oil Painting  Swirl effect   Glassy effect   Tiling effect   Paint application
Reference:

Like "IMAGE PROCESSING" page