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
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 Property
and I don't see SEGMENTATIONCHANNEL as a PROPERTY of
Measure.ThresholdTool
or
Measure.ThresholdToolCommands
Thanks again.
-- Matt
SegmentationChannel is exposed in the collection of Channels of SegmentationClass:
If you have only 1 class and only 1 channel, you can use:
or even
Public Sub PrintCurrentThresholds Debug.Print Measure.ThresholdToolCommands.Thresholds(Nothing).Classes(0).Channels(0).ThresholdMin End Sub
Yuri
Thank you for the NEW CODE.
It does the job without the loop.
I don't understand why
cannot be replaced with
or maybe
Thanks.
-- Matt
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
and it does just what is needed.
Thanks again.
-- Matt
I've revised the CODE above to take out the BLANK that precedes the THRESHOLD.
This makes it a bit easier to EDIT / set the THRESHOLD using the TEXT BOX using
where
MyThresholdTextMin = textBox_Layer03ThresholdMin.Text
and
MyThresholdTextMan = textBox_Layer03ThresholdMax.Text
-- Matt