Follow by Email

Lets Learn together... Happy Reading

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

Recent Posts

Oil Painting in MATLAB

To obtain a painting-like effect , define a small window matrix of size m by n. Copy the original image pixel values into the matrix and find the histogram of each value. Find the maximum occurring pixel value and replace the current position with the maximum occurrence value.

Original Image

Oil Paint Effect

MATLAB CODE:
A=imread('aish.jpg');

%Define the matrix size of  your convience.
m=5;
n=6;
Image=uint8(zeros([size(A,1)-m,size(A,2)-n,3]));
%Calculate the histogram for each RGB value.
for v=1:3

for i=1:size(A,1)-m
    for j=1:size(A,2)-n
        mymask=A(i:i+m-1,j:j+n-1,v);
        h=zeros(1,256);
        for x=1:(m*n)
            h(mymask(x)+1)=h(mymask(x)+1)+1;
        end
  %Maximum occurring value and the position is obtained
        [maxvalue,pos]=max(h);
        Image(i,j,v)=pos-1;
    end
end
end
figure,imshow(Image);

SEE ALSO : Swirl effect  Cone effect    Glassy effect   Tiling effect   Paint application(coloring)
  Reference:
FOR FUN:  Create your own Photoshop effects
like button Like "IMAGE PROCESSING" page

4 comments:

SADAF said... Reply to comment

this code is working but no oil paint effect was applied
what should i do plz help :(

Aaron Angel said... Reply to comment

@SADAF
Try changing the values of m and n.

SADAF said... Reply to comment

inspite of changing the values of m and n
no change apperas in image
plz guide me wt cud be the suitable values for m and n??

SADAF said... Reply to comment

ok i have change the values n nw its working thanx
but i have another issue
actuallyi want this code in my project where m nt using imread function rather using load funtion, which can take any user specified image at run time
then wat changes should i made to this code to set path of image??
m beginner in matlab n want dis help for my final project
plz help :(

Enjoyed Reading? Share Your Views

Previous Post Next Post Home
Related Posts Plugin for WordPress, Blogger...
Google ping Hypersmash.com