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