ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Opening on binrized image
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Xylit

13 Posts

Posted - Feb 22 2012 :  05:35:26  Show Profile  Reply
Hi,

I have ha weird problem: If I am making an opening on an binarized image, I am getting a white border around the image. If I am making the opening on an 24 bit image, with only black (0,0,0) and white (255,255,255) used, I am not getting a any border around the image.

IEProc:= TImageEnProc.CreateFromBitmap(OneDimBMP);
    IEProc.ConvertToBWThreshold(127);
    IEProc.Opening(3);


So something is wrong about the border handling in binarized images or am I the one who is wrong?

I am using ImageEn 3.0.5 components for Delphi.

fab

1310 Posts

Posted - Feb 23 2012 :  10:21:21  Show Profile  Reply
Hi,
yes this is a bug of Opening method when used with black/white images.
It will be fixed in next minor version (unfortunately it was out of time for the just released 4.1.0).
Go to Top of Page

Xylit

13 Posts

Posted - Feb 24 2012 :  00:53:33  Show Profile  Reply
Okay, and when will the next minor version be released?
Go to Top of Page

fab

1310 Posts

Posted - Feb 24 2012 :  01:41:24  Show Profile  Reply
We have just released 4.1.0...
A developing version of next minor release should be available next weeks.
Go to Top of Page

Xylit

13 Posts

Posted - Apr 26 2012 :  01:14:10  Show Profile  Reply
Thanks for the code fix. The white boarders around the image are vanished, but an Opening of a 1 Bit picture and of a 24 Bit picture does not come to the same result. How is that?

First I have a binarized picture. With
proc.ConvertTo24Bit;
  proc.Opening(3);

I get a different result as with just
proc.Opening(3);

Curiously the opening (binarized picture) makes a white dot bigger instead of removing it (which is working on the 24 Bit picture).

This is the code you sent me:
procedure IEmorph1bit(Bitmap:TIEBitmap; nIter:integer; opType:integer; size:integer; invertFlag:boolean; fOnProgress: TIEProgressEvent; Sender: TObject);
var
  width, height:integer;
  sizeD2:integer;
  sum:integer;
  sumAll:integer;
  x, y, i, j, n, xx, yy:integer;
  imgI:TIEBitmap;
  imgO:TIEBitmap;
  per1: double;
begin
  sizeD2 := size div 2;

  height := Bitmap.Height;
  width := Bitmap.Width;

  imgI := Bitmap;
  imgO := TIEBitmap.Create();

  try

    imgO.Allocate(width, height, ie1g);

    if (invertFlag) then
      _Negative1BitEx(imgI);

    imgO.AssignImage(imgI);

    sumAll := size * size;
    per1 := 100 / (height);

    for n := 0 to nIter-1 do
    begin
      for y := 0 to height-1 do
      begin
        for x := 0 to width-1 do
        begin
          sum := 0;
          for i := -sizeD2 to sizeD2 do
          begin
            yy := y + i;
            if yy < 0 then
              yy := 0
            else if yy >= height then
              yy := height-1;
            for j := -sizeD2 to sizeD2 do
            begin
              xx := x + j;
              if xx < 0 then
                xx := 0
              else if xx >= width then
                xx := width-1;
              if imgI.Pixels_ie1g[xx, yy] then
                inc(sum);
            end;
          end;

          case (opType) of
            1:                // dilation
              if (sum > 0) then
                imgO.pixels_ie1g[x, y] := true;
            2:                // erosion
              if (sum < sumAll) then
                imgO.Pixels_ie1g[x, y] := false;
            3:                // dilation-erosion
              if (sum > 0) then
                imgO.Pixels_ie1g[x, y] := true;
            4:                // erosion-dilation
              if (sum < sumAll) then
                imgO.Pixels_ie1g[x, y] := false;
          end;
        end;
        if assigned(fOnProgress) then
          fOnProgress(Sender, trunc(per1 * y));

      end;

      imgI.AssignImage( imgO );
      if (opType = 4) then
        opType := 3
      else if (opType = 3) then
        opType := 4;
    end;

    if (invertFlag) then
      _Negative1BitEx(imgO);
    Bitmap.AssignImage(imgO);

  finally
    FreeAndNil(imgO);
  end;
end;


Thank you.
Go to Top of Page

fab

1310 Posts

Posted - May 01 2012 :  10:12:38  Show Profile  Reply
Hi Patrick,
I just sent a new version that should fix this problem. I'd like you try it.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: