
I=imread('1.tif');
figure; imshow(I)
figure; imhist(I);
I2=histeq(I);
figure; imshow(I2);
background=imopen(I,strel('disk',1));
figure; imshow(background)
I3=imsubtract(I,background);
figure; imshow(I3,[])
I4=imadjust(I3,stretchlim(I3),[0 1]);
figure; imshow(I4)


I=imread('2.tif');
figure; imshow(I)
I2=imread('3.tif');
figure; imshow(I2);
I3=imsubtract(I,I2);    %% Es ist auch nicht egal, welches Bild von welchem abgezogen wird
figure; imshow(I3)
figure; imshow(I3*20)   %% falls das Bild zu dunkel ist. 

----------------------------------------------------------------------------------------------------------------

Quelle:    Unbekannte Internetseite

function AusgabeBild = schwarzBunt(Bild)
 
 
[row, col, dim]=size(Bild);
Bild=double(Bild);
 
Hinter1=Bild(1,1,1);
Hinter2=Bild(1,1,2);
Hinter3=Bild(1,1,3);
Hinter=[Hinter1 Hinter2 Hinter3];
 
HinterInten=(0.299*Hinter1+0.587*Hinter2+0.114*Hinter3)/255;
for i=1:row
    for j=1:col
        if Bild(i,j,1)~=Hinter1 || Bild(i,j,2)~=Hinter2 ...
                ||Bild(i,j,3)~=Hinter3
            Inten=(0.299*Bild(i,j,1)+0.587*Bild(i,j,2) ...
                +0.114*Bild(i,j,3))/255;
            Bild(i,j,:)=Hinter*Inten/HinterInten;
        end
    end
end
AusgabeBild=uint8(Bild);