How can CODE access the TRESHOLD VALUES set by a USER ithe THRESHOLD DIALOG BOX?
All --
I have modified the
Function SetThreshold
posted by YURI during AUG-2014 in response to a query by STCB to be
Public Sub TestThresDrk ()
Dim doc1
With Measure.ThresholdTool.Gadgets.Histogram(Nothing)
.CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked
.Run()
End With
With Application.DocumentCommands.Active(Nothing)
.Run(doc1)
End With
With Measure.MeasurementsCommands.Options(Nothing)
.Segmentation.AutoFindPhase = MediaCy.IQL.Features.mcFindPhase.mcfpDarkest
.Segmentation.SegmentationType = McMMOptions.mcmmSegmentationType.mcmmstThresholdSegmentation
.Run(doc1)
End With
With Measure.ThresholdToolCommands.Thresholds(Nothing)
.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(){0R,20R}))
.Prompt = "Please adjust threshold."
.Interactive = True
.Run(doc1)
End With
With Measure.ThresholdTool.Gadgets.Histogram(Nothing)
.CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Unchecked
.Run()
End With
End Sub
Public Sub TestThresMan ()
Dim doc1
With Measure.ThresholdTool.Gadgets.Histogram(Nothing)
.CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked
.Run()
End With
With Application.DocumentCommands.Active(Nothing)
.Run(doc1)
End With
With Measure.MeasurementsCommands.Options(Nothing)
.Segmentation.AutoFindPhase = MediaCy.IQL.Features.mcFindPhase.mcfpManual
.Segmentation.SegmentationType = McMMOptions.mcmmSegmentationType.mcmmstThresholdSegmentation
.Run(doc1)
End With
With Measure.ThresholdToolCommands.Thresholds(Nothing)
.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(){0R,20R}))
.Prompt = "Please adjust threshold."
.Interactive = True
.Run(doc1)
End With
With Measure.ThresholdTool.Gadgets.Histogram(Nothing)
.CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Unchecked
.Run()
End With
End Sub
Where I can call
TestThresDrk
when I want the USER to start "fresh" with an AUTODARK THRESHOLD and I can call
TestThresMan
when I want the USER to start with the CURRENT THRESHOLD.
???
How do I access the THRESHOLD VALUES that are set by the user so that I can report these in the DATA FILE?
Thanks.
-- Matt
I have modified the
Function SetThreshold
posted by YURI during AUG-2014 in response to a query by STCB to be
Public Sub TestThresDrk ()
Dim doc1
With Measure.ThresholdTool.Gadgets.Histogram(Nothing)
.CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked
.Run()
End With
With Application.DocumentCommands.Active(Nothing)
.Run(doc1)
End With
With Measure.MeasurementsCommands.Options(Nothing)
.Segmentation.AutoFindPhase = MediaCy.IQL.Features.mcFindPhase.mcfpDarkest
.Segmentation.SegmentationType = McMMOptions.mcmmSegmentationType.mcmmstThresholdSegmentation
.Run(doc1)
End With
With Measure.ThresholdToolCommands.Thresholds(Nothing)
.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(){0R,20R}))
.Prompt = "Please adjust threshold."
.Interactive = True
.Run(doc1)
End With
With Measure.ThresholdTool.Gadgets.Histogram(Nothing)
.CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Unchecked
.Run()
End With
End Sub
Public Sub TestThresMan ()
Dim doc1
With Measure.ThresholdTool.Gadgets.Histogram(Nothing)
.CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked
.Run()
End With
With Application.DocumentCommands.Active(Nothing)
.Run(doc1)
End With
With Measure.MeasurementsCommands.Options(Nothing)
.Segmentation.AutoFindPhase = MediaCy.IQL.Features.mcFindPhase.mcfpManual
.Segmentation.SegmentationType = McMMOptions.mcmmSegmentationType.mcmmstThresholdSegmentation
.Run(doc1)
End With
With Measure.ThresholdToolCommands.Thresholds(Nothing)
.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(){0R,20R}))
.Prompt = "Please adjust threshold."
.Interactive = True
.Run(doc1)
End With
With Measure.ThresholdTool.Gadgets.Histogram(Nothing)
.CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Unchecked
.Run()
End With
End Sub
Where I can call
TestThresDrk
when I want the USER to start "fresh" with an AUTODARK THRESHOLD and I can call
TestThresMan
when I want the USER to start with the CURRENT THRESHOLD.
???
How do I access the THRESHOLD VALUES that are set by the user so that I can report these in the DATA FILE?
Thanks.
-- Matt
0
Best Answers
-
Matt,
The Threshold commands reads current parameters when initialized, so you can get the values using the macro like this:
Public Sub PrintCurrentThresholds With Measure.ThresholdToolCommands.Thresholds(Nothing) For Each cl As SegmentationClass In .Classes Debug.Print cl.Channels(0).ThresholdMin & ", " & cl.Channels(0).ThresholdMax Next End With End Sub
Regards,
Yuri0 -
Yes, if you need just one property of the command, you can call it without "With":
Debug.Print Measure.ThresholdToolCommands.Thresholds(Nothing).Classes(0).Channels(0).ThresholdMin
Yuri0
Answers
-
Yuri --
Thank you for the reply and the SAMPLE CODE.
The code accesses the THRESHOLDMIN and THRESHOLDMAX values that I'm looking for so this will show ANSWERED.
Additional information please . . .
If I know I just have one class, is there a simpler version of this?
When I try to do this with a single command, I do not see the
THRESHOLDMIN
THRESHOLDMAX
or
CLASSES
PROPERTY for
Measure.ThresholdToolCommands.Thresholds
or
Measure.ThresholdToolCommands.Thresholds.Thresholds
and I don't see
Measure.ThresholdToolCommands.Thresholds.SegmentationClass
Measure.ThresholdToolCommands.Thresholds.Classes
or
Measure.ThresholdToolCommands.Thresholds.Channels
THRESHOLDMIN seems to be only documented in AUTOMATION HELP as a property of
ThresholdMin PropertyAutomation Reference ► MediaCy.Addins.ThresholdTool ► SegmentationChannel ► ThresholdMin Visual Basic
and I don't see SEGMENTATIONCHANNEL as a PROPERTY of
Measure.ThresholdTool
or
Measure.ThresholdToolCommands
Thanks again.
-- Matt
0 -
Matt,
SegmentationChannel is exposed in the collection of Channels of SegmentationClass:Automation Reference ► MediaCy.Addins.ThresholdTool ► SegmentationClass ► Channels
If you have only 1 class and only 1 channel, you can use:Public Sub PrintCurrentThresholds With Measure.ThresholdToolCommands.Thresholds(Nothing) Debug.Print .Classes(0).Channels(0).ThresholdMin End With End Sub
or evenPublic Sub PrintCurrentThresholds Debug.Print Measure.ThresholdToolCommands.Thresholds(Nothing).Classes(0).Channels(0).ThresholdMin End Sub
Yuri0 -
Yuri --
Thank you for the NEW CODE.
It does the job without the loop.
I don't understand whyWith Measure.ThresholdToolCommands.Thresholds(Nothing) Debug.Print .Classes(0).Channels(0).ThresholdMin End With
cannot be replaced withDebug.Print Measure.ThresholdToolCommands.Thresholds.Classes(0).Channels(0).ThresholdMin
or maybeDebug.Print Measure.ThresholdToolCommands.Thresholds(Nothing).Classes(0).Channels(0).ThresholdMin
Thanks.
-- Matt
0 -
Yuri --
Thank you for your reply on 20-JUN.
I've been working on other sections of this project and have just implemented your suggested SINGLE STATEMENT version of the CODE to access the THRESHOLD VALUES.
In my code I have'Update the dialog box textBox_Layer03ThresholdMin.Text = _ Str(Measure.ThresholdToolCommands.Thresholds(Nothing).Classes(0).Channels(0).ThresholdMin) textBox_Layer03ThresholdMax.Text = _ Str(Measure.ThresholdToolCommands.Thresholds(Nothing).Classes(0).Channels(0).ThresholdMax)
and it does just what is needed.
Thanks again.
-- Matt
0 -
All --
I've revised the CODE above to take out the BLANK that precedes the THRESHOLD.'Update the dialog box textBox_Layer03ThresholdMin.Text = _ Trim(Str(Measure.ThresholdToolCommands.Thresholds(Nothing).Classes(0).Channels(0).ThresholdMin)) textBox_Layer03ThresholdMax.Text = _ Trim(Str(Measure.ThresholdToolCommands.Thresholds(Nothing).Classes(0).Channels(0).ThresholdMax))
This makes it a bit easier to EDIT / set the THRESHOLD using the TEXT BOX usingTry If ( ( MyThresholdTextMin = "" ) And ( MyThresholdTextMax = "" ) ) _ Then With Measure.ThresholdToolCommands.Thresholds(Nothing) .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(){0R,20R})) .Prompt = "Please adjust threshold." .Interactive = True .Run(ThisApplication.ActiveDocument) End With Else With Measure.ThresholdToolCommands.Thresholds(Nothing) .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() _ { _ Val(MyThresholdTextMin), _ Val(MyThresholdTextMax) _ })) .Prompt = "Please adjust threshold." .Interactive = True .Run(ThisApplication.ActiveDocument) End With End If Catch 'Do nothing Finally 'Do nothing End Try
where
MyThresholdTextMin = textBox_Layer03ThresholdMin.Text
and
MyThresholdTextMan = textBox_Layer03ThresholdMax.Text
-- Matt
0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions