![]() |
|
#6
|
|||
|
|||
![]() все уже ок. удалил глобальные переменные, точней заменил их на локальные в процедуре и все стало работать как нужно.
Код:
procedure TForm1.FindDiff; var x,y:integer; p1,p2:TRGBTriple; a1,a2,a3:PRGBTripleArray; res:TBitmap; paintOver,f1,f2:boolean; r1min,r1max,g1min,g1max,b1min,b1max:integer; r2min,r2max,g2min,g2max,b2min,b2max:integer; const w:TRGBTriple=(b:255;g:255;r:255); begin f1:=filterVoter.Checked; f2:=filtersilver.Checked; r1min:=Filter1Rmin.Value; r1max:=Filter1Rmax.Value; g1min:=Filter1Gmin.Value; g1max:=Filter1Gmax.Value; b1min:=Filter1Bmin.Value; b1max:=Filter1Bmax.Value; r2min:=Filter2Rmin.Value; r2max:=Filter2Rmax.Value; g2min:=Filter2Gmin.Value; g2max:=Filter2Gmax.Value; b2min:=Filter2Bmin.Value; b2max:=Filter2Bmax.Value; res:=TBitmap.Create; res.PixelFormat := pf24bit; res.Width := bmp1.Width; res.height:=bmp1.height; for y:=0 to bmp1.Height-1 do begin a1:=PRGBTripleArray(bmp1.ScanLine[y]); a2:=PRGBTripleArray(bmp2.ScanLine[y]); a3:=PRGBTripleArray(res.ScanLine[y]); for x := 0 to bmp1.width-1 do begin p1:=a1[x]; p2:=a2[x]; if not same(p1,p2) then begin paintOver:=true; if f1 then if IsColorDiff_InRange(p2,r1min,r1max,g1min,g1max,b1min,b1max) then paintOver:=false; if (f2) and (paintOver) then if IsColorDiff_InRange(p2, r2min,r2max,g2min,g2max,b2min,b2max) then paintOver:=false; if paintOver then a3[x]:=p2 else a3[x]:=w; end else a3[x]:=w;//закрашиваем пиксель в белый цвет end; end; img1.width:=res.Width; img1.Height:=res.Height; img1.Picture.Assign(res); Detect(res,((HeightWidth.Value*HeightWidth.Value) div 100)*BWPorog.Position); res.Free; end; |