Closing images
Hello,
I am new to programming macros in Image Pro. I want to batch process 1200 images. The batch process macro will:
I am new to programming macros in Image Pro. I want to batch process 1200 images. The batch process macro will:
- flatten the image
- manually threshold objects (from a file) in the image
- Count objects
- Send count measurements to Data Collector
- Create a mask of the counted objects
- Save mask via quick publication
- Close mask and image
Public Function Counting_3() As SimpleScript
Counting_3 = New SimpleScript
Dim doc1, image1, doc2, varList1
With Application.DocumentCommands.Active(Counting_3)
.Run(doc1)
End With
With Process.Filter.EnhancementCommands.Flatten(Counting_3)
.BrightOnDark = False
.FeatureWidth = 20
.Run(doc1, doc1)
End With
With Measure.ThresholdToolCommands.Open(Counting_3)
.FileName = ThisApplication.Path(mcPathType.mcptConfigurationFiles) & "Threshold, 6-21 vent-S7.rge"
.FilterIndex = 1
.Run(doc1)
End With
With Application.RibbonCommands.SelectRibbonTab(Counting_3)
.TabName = "CountSize"
.Active = False
.Run()
End With
With Measure.MeasurementsCommands.ExecuteCount(Counting_3)
.Run(doc1)
End With
With Measure.ThresholdTool.Gadgets.Histogram(Counting_3)
.CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Unchecked
.Run()
End With
With Application.RibbonCommands.SelectRibbonTab(Counting_3)
.TabName = "Share"
.Active = False
.Run()
End With
With Measure.Data.CollectorCommands.Collect(Counting_3)
.Image = .GetImage("Measure.Data.Collector.Collect")
.Run(New List({doc1}))
End With
With Application.RibbonCommands.SelectRibbonTab(Counting_3)
.TabName = "CountSize"
.Active = False
.Run()
End With
With Measure.Measurements.CreateCommands.Mask(Counting_3)
.Run(doc1, image1)
End With
With Application.DocumentCommands.Activate(Counting_3)
.Run(image1, doc2)
End With
With Application.RibbonCommands.SelectRibbonTab(Counting_3)
.TabName = "Capture"
.Active = False
.Run()
End With
With Application.WindowCommands.QuickSaveSelectedForPublication(Counting_3)
.Run(varList1)
End With
With Application.RibbonCommands.SelectRibbonTab(Counting_3)
.TabName = "View"
.Active = False
.Run()
End With
With Application.DocumentCommands.CloseAllViews(Counting_3)
.Run(ThisApplication.ActiveImage)
End With
With Application.DocumentCommands.Activate(Counting_3)
.Run(doc1, doc1)
End With
End Function
0
Best Answer
-
Hi misbrit2128,
You can add CloseAll command in the end of the macro:With Application.WindowCommands.CloseAll(Counting_3) .Run() End With
Yuri0
Answers
I got it to work. Thank you.