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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Opening on binrized image

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Xylit Posted - Feb 22 2012 : 05:35:26
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.
5   L A T E S T    R E P L I E S    (Newest First)
fab Posted - May 01 2012 : 10:12:38
Hi Patrick,
I just sent a new version that should fix this problem. I'd like you try it.
Xylit Posted - Apr 26 2012 : 01:14:10
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.
fab Posted - Feb 24 2012 : 01:41:24
We have just released 4.1.0...
A developing version of next minor release should be available next weeks.
Xylit Posted - Feb 24 2012 : 00:53:33
Okay, and when will the next minor version be released?
fab Posted - Feb 23 2012 : 10:21:21
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).