Tuesday, December 3, 2013

Write a program in MatLab to remove background of an image.


clc;
clear all;
close all;

f=imread('n.jpg');
f=rgb2gray(f);
sub=zeros(size(f));
[ROW COLUMN]=size(sub);
f=im2double(f);

% Global Thresholding
T=0.5*(min(f(:))+max(f(:)));
done=false;
while ~done
    g=f>=T;
    Tn=0.5*(mean(f(g))+mean(f(~g)));
    done=abs(T-Tn)<0.1;
    T=Tn;
end
r=im2bw(f,T);
R=double(r);
%Image Subtraction
for i=1:ROW
        for j=1:COLUMN
            sub(i,j)=R(i,j)-f(i,j);
        end
end
% Sliding Neighborhood Normalization
fun = @(x) mode(x(:));
B = nlfilter(sub,[3 3],fun);

figure;
subplot(2,2,1),imshow(f),title('Original Image');
subplot(2,2,2),imshow(r),title('Global Thresholding - Iterative Method');
subplot(2,2,3),imshow(sub),title('Subtracted Image');
subplot(2,2,4),imshow(B),title('Final Result');

35 comments:

  1. it's realy helpful......good job

    ReplyDelete
  2. Freelance Best Makeup & Hair Artist in Jaipur with huge experience and Specialization in Bridal and Wedding Makeup,Celebrity Makeup,Professional Makeup,Creative Makeup,Bollywood Makeup and Character Makeup in Delhi,Jaipur,Rajasthan. Natural Makeup that allows your skin to breath with a radiant glow and remains flawless throughout your special day.
    Best makeup and hairstyle in jaipur
    Fiza makeup academy in jaipur
    Best bridal makeup artist in jaipur(bollywood makeup,creative makeup,Airbrush makeup,character makeup)
    Make up and Hair kit
    Professional makeup artist course in jaipur
    Fiza Makeup and hairstyle tips
    Fiza Makeup and hair Images
    Fiza Makeup and hair tutorials
    Fiza Makeup and hair contract

    ReplyDelete
  3. I read this article carefully. This is really so good post for background removal. Also I know some providers who are giving good
    Background Removal Service
    .

    ReplyDelete
  4. can you extract fire from the image in matlab???

    ReplyDelete
  5. Product Image Background Removal Services image background removal is very important especially if you have product images to upload on an eCommerce store. You require uniformity of images all over the website and white background give them a professional touch. Imagine if you have to remove background of hundreds of hellip

    ReplyDelete
  6. When I need to get service for Photo Editing, Then I choose Phtotoeditexperts as my first choice. Background Remove Service is one of the best service of them. I would recomond this site.

    ReplyDelete
  7. You have described here best resources. thanks a lot. see my website

    ReplyDelete
  8. Thanks and that i have a neat supply: What House Renovations Need Council Approval house renovation near me

    ReplyDelete