How can I automate setting the draw region of the camera control to 100 pixel square on live images?
I am guessing it is something to do with mcatSubRegion but I don't know how to set the co-ordinates and width with height programmatically. I cannot find documentation on MediaCy.IQL mcatSubRegion.
0
Best Answers
-
You are correct that the mcatSubRegion attribute will set the capture region. However, there is a higher level method that is easier to implement that contains all of the commonly used camera settings. The macro script below shows how to set the capture region to (0, 0, 100, 100) for preview and (0, 0, 200, 200) for capture. Note that if you have capture and preview settings locked, than the last set value will apply for both of them. In this case then it would be (0, 0, 200, 200) if the lock was active.
Public Function CaptRegion() As SimpleScript CaptRegion = New SimpleScript With Capture.CaptureCommands.Settings(CaptRegion) .PreviewSettings = True .SubRegion = New System.Drawing.Rectangle(0, 0, 100, 100) .Run() End With With Capture.CaptureCommands.Settings(CaptRegion) .PreviewSettings = False .SubRegion = New System.Drawing.Rectangle(0, 0, 200, 200) .Run() End With End Function
0 -
Many thanks Yuri this just what I need.
Best wishes,
Chris
0
Answers
-
Many thanks Trey - now all I have to do is figure out how to get the individual pixel intensity data in to a 2 dimensional array so I can edit by row or column0
-
Chris,
The easiest way is to use Bitmap view (Image tab). It will give you a table of pixel intensities, which you can export to Excel.
Yuri0 -
Hi Yuri - I am trying to automate some calculations and comparisons of pixel (100x100) intensity for up to 3 images and as part of this process I will want to strip off a column or a row of pixels and I think this will be easier to do by ReDim of a two dimensional array (Bitmap(X,Y) of the Bitmap integer data. I don't know the command to access this live data as BitmapViewCommands appears to be about exporting ('Shelling') to other applications as opposed to an internal array variable.0
-
Hi Chris,
If you want to work with pixel intensities there are existing tools in Calc (Process tab) with full set of arithmetical and logical operations.
If you want to use your own routines you can use macro functions to access pixels, (GetArea). Here is the example:Public Sub ReadPixelIntensities Dim im As McImage=ThisApplication.ActiveImage If im Is Nothing Then Exit Sub If im.NumberOfChannels>1 Then Exit Sub'the sample is only for single channel images Dim pixValues As Object=Nothing 'the function will read values to 2D array (or 3D for multi-channel images) im.GetArea(pixValues) 'check dimensions Dim width As Integer=pixValues.GetUpperBound(0)+1 Dim height As Integer=pixValues.GetUpperBound(1)+1 For i As Integer=0 To height-1 For j As Integer=0 To width-1 'print values Debug.Print(String.Format("Value({0},{1})={2}",j,i,pixValues(j,i))) Next Next End Sub
Regards,
Yuri0
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