Sie sind auf Seite 1von 2

function ConvertToGrayscale(MInputR,MInputG,MInputB:Matriks):Matriks; var i,j : integer; MOutputR,MOutputG,MOutputB : Extended; MOutput:Matriks; begin SetLength(MOutput,Length(MInputR), Length(MInputR[0])); for i:=0 to Length(MOutput)-1 do begin

for j:= 0 to Length(MOutput[0])-1 do begin MOutputR:=(0.2989*MInputR[i,j]); MOutputG:=(0.5870*MInputG[i,j]); MOutputB:=(0.1140*MInputB[i,j]); MOutput[i,j]:= Round(MOutputR+MOutputG+MOutputB); end; end; ConvertToGrayscale:=MOutput ; end; function PrewittOperator(MInput:Matriks;Mode:integer):Matriks; var i,j,k,l,index,Sx,Sy,POutput:integer; MOutput : Matriks; ArrP:TFilter; begin SetLength(MOutput,Length(MInput)-2,Length(MInput[0])-2); SetLength(ArrP,9); for i:= 0 to Length(MOutput)-1 do begin for j:= 0 to Length(MOutput[0])-1 do begin index:=0; for k:=i to i+2 do begin for l:=j to j+2 do begin ArrP[index]:=Minput[k,l]; index:=index+1; end; end; Sx:=abs(-1*(Arrp[0]+ ArrP[1]+ArrP[2])+ArrP[6]+ ArrP[7]+ArrP[8]); Sy:=abs(-1*(Arrp[0]+ ArrP[3]+ ArrP[6])+ ArrP[2]+ ArrP[5]+ArrP[8]); Case mode of 1:POutput:=Sx+Sy; 2:POutput:=Max(Sx,Sy); 3:POutput:=round((Sx+Sy)/2); 4:POutput:=round(sqrt(Sx*Sx+Sy*Sy)); end; if POutput > 255 then POutput:=255; if Poutput<120 then Poutput:=0; MOutput[i,j]:=POutput; end; end; PrewittOperator:=MOutput;

end; MatriksImageOutput:=ConvertToGrayscale(MatriksRImageOutput,MatriksGImageOutput, MatriksBImageOutput); BitmapImageOutput:= MatriksToImageRGB(MatriksImageOutput,MatriksImageOutput, MatriksImageOutput);

Das könnte Ihnen auch gefallen