After reading a couple of image processing books, I tried to implement some Photoshop effects in MATLAB. First, I tried to implement the twirl effect in MATLAB.
The mid point of the image is stored in the variables ‘midx’ and ‘midy’.
The angle and the radius for each point in the image are found by converting the co-ordinates from Cartesian to polar co-ordinates.
The effect can be obtained by using the following formula:
new[rho , theta] = old[rho , theta + rho /K] .
By changing the value of K, the swirl can be increased or decreased.
For more fun, try this effect with your own photography image.
Additional Information: Learn to make your own Photoshop effects
so that you can code your own effects.
For beginners in photoshop
: Read photoshop for dummies
.
The effect can be obtained by using the following formula:
new[rho , theta] = old[rho , theta + rho /K] .
By changing the value of K, the swirl can be increased or decreased.
For more fun, try this effect with your own photography image.
Additional Information: Learn to make your own Photoshop effects
For beginners in photoshop
MATLAB CODE:
A=imread('flower2.jpg');
B=uint8(zeros(size(A)));
figure,imshow(A);
%Mid point of the image
midx=ceil((size(A,1)+1)/2);
midy=ceil((size(A,2)+1)/2);
![]() |
K=150 |
K=100;
x2=zeros([size(A,1) size(A,2)]);
y2=zeros([size(A,1) size(A,2)]);
for i=1:size(A,1)
x=i-midx-K;
for j=1:size(A,2)
%Cartesian to Polar co-ordinates
[theta1,rho1]=cart2pol(x,j-midy+K);
phi=theta1+(rho1/K);
%Polar to Cartesian co-ordinates
[l,m]=pol2cart(phi,rho1);
x2(i,j)=ceil(l)+midx;
y2(i,j)=ceil(m)+midy;
end
end
%The result may produce value lesser than 1 or greater than the image size.
x2=max(x2,1);
x2=min(x2,size(A,1));
y2=max(y2,1);
y2=min(y2,size(A,2));
x2=max(x2,1);
x2=min(x2,size(A,1));
y2=max(y2,1);
y2=min(y2,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 |
Reference:
- Algorithms for Graphics and Image Processing
- Beyond photography: The Digital Darkroom
FOR FUN: Create your own Photoshop effects
3 comments:
How to implement different color tint on image using matlab?
how can we implement different color tint on iimage using matlab?
its really good but pretty confusing so can u plz explain a bit more about the code ans how u have implemented it.
Enjoyed Reading? Share Your Views