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
 IEVision - Unspecified Error
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

yogiyang

India
725 Posts

Posted - May 07 2019 :  03:23:47  Show Profile  Reply
Hello,

I am trying to integrate WaterShed to select pixels based on red color and green color markers.

I am using following code (most of the code is taken from the sample provided):

  wsq: TIEVisionWatershed;

  wsq := IEVisionLib().createWatershed();

  // Code to Create Selection
  wsq.setMarkers(0);
  wsq.setMarkers(ImageEnViewMain.Layers[1]
    .Bitmap.GetIEVisionImage());
  ImageEnViewMain.Layers[1].Bitmap.origin := ieboBOTTOMLEFT;
  wsq.run();

  ImageEnViewMain.LayersCurrent := 0;
  ImageEnViewMain.Deselect();
  wsq.getSelectionMask(ImageEnViewMain.SelectionMask, Integer(REGION2COLOR[1]));
  ImageEnViewMain.SelectCustom();
  ImageEnViewMain.Layers[1].Visible := False;
  ImageEnViewMain.Update;



Code in OnMouseMove Event:

if RadioGroupDefineRegion.ItemIndex > 1 then
      exit;

    if rgModes.ItemIndex > 0 then
      exit;

    bmpX := ImageEnViewMain.XScr2Bmp(X);
    bmpY := ImageEnViewMain.YScr2Bmp(Y);
    if (ImageEnViewMain.LayersCount > 1) and (ssLeft in Shift) and (bmpX >= 0) and
      (bmpY >= 0) and (bmpX < ImageEnViewMain.IEBitmap.Width) and
      (bmpY < ImageEnViewMain.IEBitmap.Height) then
    begin
      ellipsRect := Rect(bmpX - ELLIPSRAY, bmpY - ELLIPSRAY, bmpX + ELLIPSRAY,
        bmpY + ELLIPSRAY);

      // draw on layer1 bitmap canvas
      with ImageEnViewMain.Layers[1].Bitmap.Canvas do
      begin
        Pen.Color := REGION2COLOR[RadioGroupDefineRegion.ItemIndex];
        Brush.Color := Pen.Color;
        Ellipse(ellipsRect);
      end;

      // draw on layer1 bitmap alpha (to make painted ellipse visible)
      ImageEnViewMain.Layers[1]
        .Bitmap.AlphaChannel.CanvasCurrentAlpha := 255;
      with ImageEnViewMain.Layers[1].Bitmap.AlphaChannel.Canvas do
      begin
        Ellipse(ellipsRect);
      end;

      ImageEnViewMain.UpdateRect(Rect(X - ELLIPSRAY, Y - ELLIPSRAY, X + ELLIPSRAY,
        Y + ELLIPSRAY), true);

    end;


Code in Button Click Event:

  wsq.setMarkers(0);
  wsq.setMarkers(ImageEnViewMain.Layers[1]
    .Bitmap.GetIEVisionImage());
  ImageEnViewMain.Layers[1].Bitmap.origin := ieboBOTTOMLEFT;
  wsq.run();

  ImageEnViewMain.LayersCurrent := 0;
  ImageEnViewMain.Deselect();
  wsq.getSelectionMask(ImageEnViewMain.SelectionMask, Integer(REGION2COLOR[1]));
  ImageEnViewMain.SelectCustom();
  ImageEnViewMain.Layers[1].Visible := False;
  ImageEnViewMain.Update;


I am getting error when wsq.run(); is executed.

What must be the problem?

TIA


Yogi Yang

yogiyang

India
725 Posts

Posted - May 07 2019 :  07:12:37  Show Profile  Reply
Hello,

Problem is solved.

I had forgotten to initialize wsq.setInputImage.

I did that and now things are working fine.




Yogi Yang
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: