CODE to perform a SNAPSHOT within an ROI . . .
2021-10-13-172317
All --
I am looking for the equivalent of the SNAPSHOT COMMAND but I would like the image that is the result to be just the ROI.
So as an example . . .
I have an image that is 3000 x 3000 pixels. I would like to work with an ROI that is 1000 x 1000. I have done a COUNT in the ROI. Now I would like a SNAPSHOT of just the ROI.
Here is an illustration with:
-- AA on the left being the 3000 x 3000 image with the 1000 x 1000 ROI with the COUNT within it
-- BB on the right being the SNAPSHOT of the 1000 x 1000 ROI with the COUNT burned into it.

I did this manually by:
-- Saving the ROI from AA in the FEATURES MANAGER
-- Doing a SNAPSHOT on AA
-- Recalling the ROI from AA into the SNAPSHOT
-- Cropping the 3000 x 3000 pixel SNAPSHOT to the appropriate 1000 x 1000 SNAPSHOT
-- Deleting the 3000 x 3000 pixel SNAPSHOT
The result of these steps is BB.
Is there an efficient way to do this with CODE or should I write CODE to perform the steps that I did manually to get from AA to BB?
I know that I could CROP AA to the ROI before doing the COUNT, do a COUNT on the CROPPED IMAGE, and then do a SNAPSHOT of the CROPPED + COUNTED IMAGE but I would like to avoid working with an INTERMEDIATE IMAGE if possible.
Thanks.
-- Matt
0
Best Answer
-
Hi Matt,
There is no direct option to do what you want, but here is a macro that does it executing your steps on invisible image:Public Sub SnapshotOfROI Dim im As McImage=ThisApplication.ActiveImage Dim image1 As McImage With Application.WindowCommands.Snap(Nothing) .Visible=False'create invisible snapshot .Run(ThisApplication.ActiveWindow, image1) End With 'apply original image ROI image1.Aoi.CopyFrom (im.Aoi) 'duplicate and make it visible image1.Duplicate(mcImageCreateFlags.mcicfDefault).Visible=True image1.Close End Sub
This macro leaves ROI outline on snapshot.
And here is the macro that does't have ROI outlinePublic Sub SnapshotOfROIWithoutGreenBorder Dim im As McImage=ThisApplication.ActiveImage Dim image1 As McImage Dim roi =im.Aoi.Duplicate'save the ROI 'Clear ROI To avoid green line On screenshot im.Aoi.Reset With Application.WindowCommands.Snap(Nothing) .Visible=False'create invisible snapshot .Run(ThisApplication.ActiveWindow, image1) End With im.Aoi.CopyFrom (roi)'restore original ROI 'apply original image ROI image1.Aoi.CopyFrom (im.Aoi) 'duplicate and make it visible image1.Duplicate(mcImageCreateFlags.mcicfDefault).Visible=True image1.Close End Sub
Yuri0
Answers
-
2021-10-14-160338Yuri --Those routines are SUPER.I hotwired them into the APP and they both work great.I think thatSnapshotOfROIwill be the one that we use but it is nice to have the option.Thank you.-- 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