Home Image-Pro Automation (Macros, Apps, Reports)

Crop Images into smaller images

I am trying to work on a set of some very large images. My computer always freezes. I found that if I crop them into pieces I can do the analysis on each piece. Is there a way I a macro can crop the image into 4 or 6 images and do the analysis automatically?



  • 2018-04-02-101638

    Matt321 --

    If CROPPING the IMAGE and then analyzing the smaller IMAGE works it seems it would be possible to use multiple ROIs in sequence to perform the same type of operation.  This might be easier to handle and potentially you could save the results from each ROI and then bring them all back into the image as a SUMMARY.

    Either operation can be automated with using the PROJECT WORKBENCH but I think that automating the ROI option would be easier for a novice than the MULTIPLE IMAGE option.

    If you turn on the RECORD MACRO TOOL and perform your ROI OPERATIONS or CROPPING OPERATIONS, then STOP RECORDING, the code that is generated should be a good start to a MACRO or an APP that would do what you want.

    I hope this information is helpful.

    -- Matt
  • edited April 2018
    Hi Matt321,

    You can use the macro below as an example. It shows how the processing can be done using a loop and ROIs. The macro will go through the image creating ROIs of smaller size and calling DoROIProcessing function for every ROI. The sample macro just crops the ROI to a separate image, but you can extent it to add the processing you need.

        'process large image by smaller areas
        Public Sub ProcessImageByAreas
            Dim im As McImage=ThisApplication.ActiveImage
            If im Is Nothing Then Exit Sub
            'ROI parameters,
            Dim w As Integer=500'ROI width
            Dim h As Integer=500'ROI height
            Dim roi As Mediacy.IQL.Features.IMcRegions=im.Aoi'image ROI object
            'loop through smaller areas
            For i As Integer=0 To im.Height Step h
                For j As Integer=0 To im.Width Step w
                    'activate the original window
        End Sub
        'do processing of single ROI
        Private Sub DoROIProcessing
            'for example - crop
            'or do something else...
        End Sub

    I've also attached the complete project.

Sign In or Register to comment.