function Im=preprocess(Im)
[m n]=size(Im);
BW = im2bw(Im,0.0706);
%figure, imshow(BW);
L = bwlabel(BW,8);
STATS = regionprops(L, 'Area');
[m1 n1]=size(STATS);
for kk=1:m1
vect(kk)=STATS(kk).Area;
end
BW2 = bwareaopen(L,max(vect),8);
% figure,imshow(L);
% figure,imshow(BW2);

BW3 = bwmorph(BW2,'clean');
%figure, imshow(BW3)
BW3 = bwmorph(BW3,'majority');
%figure, imshow(BW3);

se = strel('disk',5); 
IM2 = imerode(BW3,se);
IM2 = imdilate(IM2, se);
BW4 = imfill(IM2,'holes');
Z = immultiply(BW4,Im);
%figure,imshow(Z);

 J = imadjust(Z,stretchlim(Z),[]);
 %figure, imshow(J)
 
Im=J;