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)
k=imadjust(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: