Use McLines to create a mask problem

Dear Sir,

My algorithm will generate some negative value coordinates.
When McLines BoundingRect has negative value will make IP10 crash by using  CreateFeatureMask command.
Is there  has any command to cut the invisible part directly?

[Code]
Dim tmpim As McImage = im.Duplicate(mcImageCreateFlags.mcicfNotVisible)
Dim lnDrawRgn As McLines = tmpim.LineFeatures
lnDrawRgn.Reset()
Dim dline(1) As System.Drawing.PointF
For i = 0 To splitPtL.Length - 2
dline(0).X = splitPt(i).X
dline(0).Y = splitPt(i).Y
dline(1).X = splitPtL(i).X
dline(1).Y = splitPtL(i).Y

lnDrawRgn.SetFeaturePoints(i, dline)
Next i
dim SourceMaskImg as mcimage= lnDrawRgn.CreateFeatureMask(mcFeatureMaskFlags.mcfmfDisplayMaskImage)

[Image]

By Wesan

Best Answer

• Answer ✓
Hi Wesan,

I checked your macros and would like to know the goal of your task. What are you trying to achieve or measure?
It looks like you are drawing lines from the object centroid at 1 degree step (360 lines) and then measure length?

We have Array measurements that provide such data directly (Radii, Diameters, Calipers). You can see all the values in the Object window.

By default 32 values are generated (step angle 11.25 degrees), but you can set NumAngles to 360 and get 1 degree step.

```    Public Sub Set1DegreeStep
Dim im As McImage = ThisApplication.ActiveImage
Dim md As McMMData = im.MeasurementsData
If md.Count=0 Then Exit Sub
'adjust angle measurement parameters
Dim rgns As MediaCy.IQL.Features.McRegions= md.SubFeatures(0).GetFeatures()
Dim numAngles As Integer=360'set 1 degree angle
rgns.maRgnRadii.NumAngles=numAngles
rgns.maRgnRadii.SetValueStale
rgns.maRgnDiameters.NumAngles=numAngles
rgns.maRgnDiameters.SetValueStale
End Sub
```
The Object window will report 360 measures:

Let me know if that's what you need.

Yuri

Answers

• You can clip the coordinates to the boundaries,  like this:

dline(0).X = Math.Max(0,splitPt(i).X)

Yuri
• Thank Yuri

The line segments will have different angle, so I want to know is there had command can quickly clip the McLine.
I can calculate the coordinate value that does not exceed the image size. It's just I need to write multiple lines to do this.

Wesan
• Hi Yuri,

I have a new question.
Is there a faster way to cut off excess McLines.
I attach the code that i wrote and testing image.
I want to get the following drawing.

Wesan

• Hi Wesan,

I am on vacation till the next week. I will check your macro when I'm back.

Yuri

• Thanks yuri,

I originally thought that the Radii parameter was fixed at 32 values.  This method is very useful for me.

I draw 360-degree line to calculate the distance from the edge of the object to the fixed size circle.
Drawing 360-degree line directly see the measurement position. And the measurement value displayed at the data table.

Recently, I often use McRegions,  McLines or McFeatures  to generate measurement results because this can get the measurement data more quickly.
I wonder know if mcRegions and mcLines have any methods that can substract irregular shapes. Similar to one Image using operation to substract another image.
Or is it possible to get the intersection point of mcRegion and a Mcline?

Wesan
• Hi Wesan,

Yes, using McFeatures will generate measurement objects faster, but it's still not as fast as just getting Radii measurements. If you want to measure "the distance from the edge of the object to the fixed size circle" and the center of the circle is object's centroid, then the value can be calculated from Radii as  L(i) = Radius - Radii(i).
You can print Radii (or L) values to the Output window (ThisApplication.Output) in the table format and export it to Excel for convenience. Here is an example how to print Radii values: https://forums.mediacy.com/discussion/comment/641#Comment_641

McFeatures class have several methods for doing operations between them, such as Intersect, Merge, Maskoff, (see http://projects.mediacy.com/help/html/M_MediaCy_IQL_Features_IMcFeatures_Intersect.htm, but they work between features of the same type (e.g McLines or McRegions). If you want to do operations between regions and lines, then you should do opeations between images or McBitMask through CreateFeatureMask.(see examples http://projects.mediacy.com/help/html/M_MediaCy_IQL_Features_IMcFeatures_CreateFeatureMask.htm, note that the examples are in old VB6 syntax).

Yuri
Sign In or Register to comment.