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

Smart segmentation and measuring of ROI

Hi,

I have set up a smart segmentation and classification for a larger set of images where my colleague has already drawn ROI's in wich these measurements will be applied. 

I have created a macro to to do the counting and measuring of ROI. When I do all the steps manually, I get all the measurements I want, but when I run the Macro, I only get the ROI, no measurements from my classes.

Let me explain what I want to do;

I do smart segmentation identifying all objects, I count them and do learning classification that identifies three different classes. I then go in to Manual segmentation and get the whole ROI labelled and count that as well to get the area of the ROI. Under measurement options I have checked "preserve existing data". So, when I do the steps manually and while setting up the macro, I had a data table with all my objects from the classification, plus the measurement for the ROI as a separate class. When I run the macro, all I get is the last measurement, the ROI.

I am enclosing a screeshot of how the macro looks, since I cannot seem to attach the macro file. 

Best Answers

  • Options
    Answer ✓
    Hi Josephine,

    I see that you have several commands that open options file, and change options, it could change the state of "preserve existing data" flag.
    You can debug your macro step by step and see where the data gets reset, just switch to the Code view, add a break point (F9) and then run the macro step-by-step using F10 button. During the debugging check the data table and the measurement options dialog and see when it changes state.

    Regards,

    Yuri

  • Options
    Answer ✓
    Hi Josephine,

    It's difficult to tell what the problem is by looking just at snippets of your macro and not the whole code.

    What I can see is that you use multiple options files and all of them are loaded from the desktop. It's recommended to have all options files (opt,lcl,isg,...) in the Configurations Files folder of Premier, in that case it will be recorded with short path
            .FileName = ThisApplication.Path(mcPathType.mcptConfigurationFiles) & "spots.isg"
    and automatically included into the packaged project (IPX).

    To help you further, can you please send me your project (IPX, save it from Project workbench - File | Package) and all related options files (if they are not in Configurations Files folder)?

    Thanks,

    Yuri

Answers

  • Options
    Hi Yuri,

    Just to begin with I have to say that I have very, very limited knowledge of programming, just so you know what you are up to ;) 

    I did as ju suggested and this is the result:

    When I click my way through the Macro I get one of two results in the end; one is the same result as before and the other is getting one more class measurement and the ROI measurement. However, the class measurement gives me the same number, objects and size as the ROI-class.

    While I click my way through it, nothing really happens until I come to the line 107, thats when I get an ROI-class measurement.

    Next time anything happens is at line 122, when classification is applied, then the ROI-class changes to the class called B, still only one measurement in the datatable though.

    After line 239 I end up with both classes, but both with the same measurements. 

    I tried recording the macro one more time, step by step, and when I record it, everything lookes right. But when I run it, the same thong happens.

    I tried looking at what os actually written in the macro and found a few things that I am curios about if it has an effect, I however have absolutely no idea how to change it...

    Early on, when the measurment options are loaded, the line under it says "Active class = 1"
    Does that mean I have to activate more classes some how? I do get measurements from two classes though, so its not completely logical...

    Also, the smart segmentation recipe that I load, i load it from the section train and save, and the classification is from learning, does that make a difference?

    What baffles me the most is that, when I do each step manually, everything turns out the way it is supposed to, but when the macro is supposed to do all the same steps, it does not work...the settings should be the same right?


    Thanks for helping!

    Best Regards Josephine






  • Options
    Thank you so much for helping! 

    Best Regards Josephine
Sign In or Register to comment.