Background Correction
I'm having problems with this. Trying to do background correction with dark objects.. This is the recorded script, but I just get a white image.
Public Sub button1_Click_1(sender As Object, e As System.EventArgs)
With Process.BackgroundCommands.Correct(Nothing)
.BlackLevel = 0R
.Run(ThisApplication.ActiveDocument, ThisApplication.ActiveDocument, Nothing)
End With
End Sub
0
Answers
-
Hi Paul,
The background correction includes 2 commands (Extract Background and Correct). You macro shows just one command. Please, try to record the macro and post it here.
What is your Premier's version?
Thanks,
Nikita.
0 -
Paul,
Your command looks edited manually the arguments in the Run function is not native. Does it work in the recorded version of the macro?
Also, there was a fix in 9.3.1 related to this command. Please try 9.3.1 (if you don't use it already).
Yuri
0 -
thanks for your comments - my recorded code is as below. When I run it I get a blank white image.
I'm still running 9.2 on this computer - perhaps I need to got to 9.3 as you suggest.Public Sub button3_Click(sender As Object, e As System.EventArgs) Handles button3.Click With Process.BackgroundCommands.Correct(Nothing) .BlackLevel = 0R .Run(ThisApplication.ActiveDocument, ThisApplication.ActiveDocument, Nothing) End With End Sub
0 -
Paul,
I recorded and tested the background correction macro in Premier. The macro looks like this (it works properly in 9.3.1):Public Function CorrectBrightBackground() As SimpleScript CorrectBrightBackground = New SimpleScript Dim doc1, image1 With Application.DocumentCommands.Active(CorrectBrightBackground) .Run(doc1) End With With Process.BackgroundCommands.Extract(CorrectBrightBackground) .BackgroundType = Background.ExtractTypes.Bright .FeatureSize = 50 .Visible = False .Run(doc1, image1) End With With Process.BackgroundCommands.Correct(CorrectBrightBackground) .BlackLevel = 0R .Run(doc1, image1, doc1) End With End Function
The easiest way to do what you need is just to call the recorded macro from your event handler (instead of copy/pasting the code), even if the recorded macro is in different VB module of your project:Public Sub button3_Click(sender As Object, e As System.EventArgs) Handles button3.Click CorrectBrightBackground End Sub
Yuri
0 -
still getting an error from .Run(doc1, image1, doc1) - specified caste is not valid
have to upgrade to 9.3 - thanks for your help anyway.0 -
Hi Paul,
There is an issue in the background commands recording/playback and we are looking on it.
The current solution is simplified macro then background image generated internally:Public Function CorrectBrightBG() As SimpleScript CorrectBrightBG = New SimpleScript Dim doc1 With Application.DocumentCommands.Active(CorrectBrightBG) .Run(doc1) End With With Process.BackgroundCommands.Correct(CorrectBrightBG) .BackgroundType = Background.BackgroundTypes.Bright .FeatureSize = 50 .BlackLevel = 0R .Run(doc1, Nothing, doc1) End With End Function
Thanks,
Nikita.
0 -
Paul, if you upgrade to 9.3, please make sure to install 9.3.1 patch as well.
Thanks,
Nikita.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