# oilspill extraction [closed]

I want to extract the oilspill affected areas in SAR images using thresholding, where the affected area appears as darker than surroundings. Here I am attaching the code, where I am able to extract the white portions in the image.

i=imread('oil.jpg');
figure(1);
imshow(i)
title('Orginal image');
% RGB to Gray conversion;
J=rgb2gray(i);
figure(2);
imshow(J)%Grayscale image
x=imresize(J,[256 256]);% converting the imagesize to 256x256
figure(3);
imshow(x)
imshow(k)
imhist(k)
y=double(k)
[m n]=size(y);
L=double(255);
% Extracting the white portion;
for i=1:m
for j=1:n
z(i,j)=0;
if y(i,j)>=100 && y(i,j)<=255
z(i,j)=L;
end
end
end
figure(4);
imshow(z)


The image I'm working on is:

• Is it really a SAR image? looks a lot like an airplane camera to me. If it is, then it was already processed to be displayed in false colors and the oil / water segmentation part has already been performed. – sansuiso Jan 23 '14 at 9:49

You are almost there, just deal with your image in the HSV space.

i=imread('http://i.stack.imgur.com/tyeUJ.jpg');
figure(1);
imshow(i)
title('Orginal image');
% RGB to Gray conversion;
% J=i(:,:,2);
ii=rgb2hsv(i);
J=ii(:,:,1);
% J=rgb2gray(i);
figure(2);
imshow(J)%Grayscale image
x=imresize(J,[256 256]);% converting the imagesize to 256x256
figure(3);
imshow(x)
imshow(k)
imhist(k)
y=double(k);
[m n]=size(y);
L=double(255);
% Extracting the white portion;
for i=1:m
for j=1:n
z(i,j)=0;
if y(i,j)<=1 && y(i,j)>=0.6 || y(i,j)<=0.1
z(i,j)=L;
end
end
end
figure(4);
imshow(z)


Note that if you want your boundary much more accurate, thresholding method will always not be the choice.