I think you have a potential bug in the IEApplyThreshold procedure in the imageenproc.pas unit.
I am simply performing a threshold operation where all pixels below ThresholdValue (e.g., 128) are being set to 0 or 255 in one case or the opposite 255 or 0 in an alternate case. I have a TIEBitmap object named ThresholdImage and makes the following call (the alternate case):
ThresholdImage.Proc.Threshold(
CreateRGB(ThresholdValue,ThresholdValue,ThresholdValue),
CreateRGB(ThresholdValue,ThresholdValue,ThresholdValue),
CreateRGB(255,255,255), CreateRGB(0,0,0) );
This function in turn calls:
procedure IEApplyThreshold(Bitmap: TIEBitmap; DownLimit, UpLimit, DownVal, UpVal: TRGB; X1, Y1, X2, Y2: Integer; OnProgress: TIEProgressEvent; Sender: TObject);
And in this procedure the following code executes:
for x := X1 to X2 do
begin
e := pRGB(ei);
if (e^.r <= DownLimit.r) then
e^.r := DownVal.r;
if (e^.g <= DownLimit.g) then
e^.g := DownVal.g;
if (e^.b <= DownLimit.b) then
e^.b := DownVal.b;
if (e^.r > UpLimit.r) then
e^.r := UpVal.r;
if (e^.g > UpLimit.g) then
e^.g := UpVal.g;
if (e^.b > UpLimit.b) then
e^.b := UpVal.b;
inc(ei, i);
end;
What happens in the case I presented is if the first IF for each r, g, b value is true it executes e^.r := DownVal.r which sets the value to 255. Then, further down it executes "if (e^.r > UpLimit.r)" and since we already changed e^.r in the first IF to 255, this second IF is true and sets e^.r := UpVal.r, i.e., it sets it to 0. I think this is wrong.
I think the code should be changed to:
if (e^.r <= DownLimit.r) then
e^.r := DownVal.r
else if (e^.r > UpLimit.r) then
e^.r := UpVal.r;
if (e^.g <= DownLimit.g) then
e^.g := DownVal.g
else if (e^.g > UpLimit.g) then
e^.g := UpVal.g;
if (e^.b <= DownLimit.b) then
e^.b := DownVal.b
else if (e^.b > UpLimit.b) then
e^.b := UpVal.b;
Thank you for considering this issue.
Tim F