1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135:
| function TfrmMain.DelVibrac(): Boolean;
var I,J, AddLength, Height, Width, NewLength,NewPos : Integer; line1vecG : array of TJmComplexRect; line2vecG : array of TJmComplexRect; line : TRGBArray; sl: TStringList; sl1: TStringList; sl2: TStringList; begin sl:=TStringList.Create; sl1:=TStringList.Create; sl2:=TStringList.Create; try Width := Length(imagematrix[0]); Height := High(imagematrix); NewLength := Width + (Width mod 2); AddLength := Width div 2; AddLength := AddLength - (AddLength mod 2); NewLength := NewLength + AddLength; SetLength(line1vecG,NewLength); SetLength(line2vecG,NewLength); Setlength(line,Width); progrbar.Max := Height -1; progrbar.Visible := True; for J:=0 to (Height - 1) do begin for I:=0 to Width - 1 do begin line1vecG[AddLength + I].Re := (imagematrix[J][I].R*0.299 + imagematrix[J][I].G*0.587 + imagematrix[J][I].B*0.114); line1vecG[AddLength + I].Im := 0.0; line2vecG[I].Re := (imagematrix[J+1][I].R*0.299 + imagematrix[J+1][I].G*0.587 + imagematrix[J+1][I].B*0.114); line2vecG[I].Im := 0.0;
line[I] := imagematrix[J+1][I]; lblstat.Caption := 'Zeile: ' + IntToStr(J); end; NewPos := GetMovePos(line1vecG,line2vecG); sl.Add(IntToStr(NewPos)); NewPos := NewPos - AddLength; sl.Add('reel: ' + IntToStr(NewPos)); MoveLine(line,NewPos,J+1); lblstat.Caption := 'Zeile: ' + IntToStr(J+1); progrbar.Position := J; Application.ProcessMessages; end; progrbar.Visible := False; DrawImageMatrix(); stretch(400,400,TResamplingFilter(1),0,imgWork.Picture.Bitmap,imgPreview.Picture.Bitmap); DelVibrac:=True; sl.SaveToFile('c:\test\test.txt'); sl.Free; sl1.SaveToFile('c:\test\vector1.txt'); sl1.Free; sl2.SaveToFile('c:\test\vector2.txt'); sl2.Free; except DelVibrac:=False; sl.Free; end; end;
function TfrmMain.GetMovePos(var vec1,vec2 : array of TJmComplexRect): Integer;
var Len,I : Integer; multivec1 : array of TJmComplexRect; multivec2 : array of TJmComplexRect; resvec : array of TJmComplexRect; resvec1 : array of TJmComplexRect; resvec2 : TDoubleArray; begin vectormiddle(vec1); vectormiddle(vec2); Len := Length(vec1); SetLength(multivec1,Len); SetLength(multivec2,Len); SetLength(resvec,Len); SetLength(resvec1,Len); SetLength(resvec2,Len); ForwardFFT(vec1,multivec1,Len); ForwardFFT(vec2,multivec2,Len); for I:= Low(multivec2) to High(multivec2) do begin multivec2[I] := CConjugateRect(multivec2[I]); resvec[I] := CMultRect(multivec1[I],multivec2[I]); end; InverseFFT(resvec,resvec1,Len); for I:= Low(resvec1) to High(resvec1) do resvec2[I] := (resvec1[I].Re); result := FindMaxIndex(resvec2); end;
function TfrmMain.FindMaxIndex(const vector : TDoubleArray): Integer; var I,Index : Integer; maxval : double; begin Index := Low(vector); maxval := 0.0; for I := Low(vector) to High(vector) do begin If maxval < vector[I] then begin maxval := vector[I]; Index := I; end; end; result:= Index; end;
procedure TfrmMain.MoveLine(linevec : TRGBArray;X,linenr : Integer); var I : Integer; begin if X > 0 then begin for I := Low(imagematrix[linenr]) to High(imagematrix[linenr]) do begin if I > (X-1) then imagematrix[linenr][I] := linevec[I-X] else begin imagematrix[linenr][I].R := 0; imagematrix[linenr][I].G := 0; imagematrix[linenr][I].B := 0; end; end; end else if X<0 then begin for I := Low(imagematrix[linenr]) to High(imagematrix[linenr]) do begin if I<(High(linevec)+X+1) then imagematrix[linenr][I] := linevec[I-X] else begin imagematrix[linenr][I].R := 0; imagematrix[linenr][I].G := 0; imagematrix[linenr][I].B := 0; end; end; end; end; |