More Measurement Outlines
Hello Yuri
You suggested making doughnut areas from a Distance map, which works well. However the code I'm using to increment the threshold level is below. How do you automatically increment the values {1R,261R} using the high level commands produced by recording the steps would mean I would have to manually input them for each cell within the image. Are there any lower level commands that would accept a variable input to change the thresholds.
With Measure.ThresholdToolCommands.Thresholds(Eroder) .AllowOverlap = False .Interpretation = eInterpretation.Mono .Classes = New System.Collections.Generic.List(Of SegmentationClass) .Classes.Add(New SegmentationClass("Class 1",System.Drawing.Color.Blue,New Double(){1R,261R})) .Run(ThisApplication.ActiveImage) End With
0
Best Answer
-
Here is another sample macro, which will print thresholds of the active image for all classes, all channels:
Public Function GetActiveThresholds() As SimpleScript GetActiveThresholds = New SimpleScript 'create command to read thresholds With Measure.ThresholdToolCommands.Thresholds(GetActiveThresholds) 'initialize it from the active document .GetFromDocument(ThisApplication.ActiveDocument) 'read the command parameters, go through all classes For Each thrClass As SegmentationClass In .Classes 'go through all channels For Each ch As SegmentationChannel In thrClass.Channels Debug.Print (thrClass.DisplayName & " = " & ch.ThresholdMin & ", " & ch.ThresholdMax) Next Next 'don't call Run! End With End Function
0
Answers
Hello Yuri
That works thanks I didn't realise that you can substitute the values in these higher level commands easily. However I have another question about them, if you can assign variables to them can you also extract data from them as I want a user to threshold an image and then be able to extract the upper and lower threshold values into a variable for use elsewhere, I need to extract them as the user wants it associated with the measurement data.
Regards
David
There is another approach that involves using command properties. It could be easier to use when you know what commands are involved.
Some commands are initialized from the active image, ThresholdTool.Thresholds is one of them.
So you can just create a command and read its properties, which will return parameters of the active image.
Sample macro:
Yuri