Home Image-Pro Plus Automation with Macros

How to draw an AOI, dilate it, bring it back and measure color intenisty in the new AOI

Hi there,

I am running IPP 7.0 and I would need some guidance on transferring outlines to AOIs.

I have a fluorophore (green) that is staining in the close proximity of blood vessels (red). I would like to measure the intensity of the green color around the blood vessel and not all the green staining in a given rectangle that I might draw by hand around the vessel.

So I was thinking of the following algorithm:

-          Draw AOI of the vessels (by hand or by using the red channel).

-          Convert the AOI to an object

-          Apply a Dilation morphological filer to the object so that its contour grows with the same number of pixels in all directions.

-          Convert back the resulting object to AOI and overlay it on the original image

-          Measure the green intensity in the new (dilated) AOI.

-          Ideally I would like to substract the original AOI from the dilated one in order to analyze only the ring area around the vessel!

What I did until now was to (1) define first an AOI (freehand or by channel color), (2) convert the AOI to objects, (3) in the Count/Size menu Make Mask, and thus obtain a new image with my AOI as an object. (4) Next on this binary image I applied a dilate morphological filer and the mask grew eccentrically from the original outline with the same number of pixels in al directions. (5) I used the automated threshold (Count/Size) to select the dilated AOI, (6) then Count to generate an object, then (7) I saved the outlines of the object, and lastly, on the original image (8) load outlines. But here the problem is that I cannot make the measurement only inside the outline…

Please, if you have any ideas how this might work best, I would greatly appreciate it!

I am not so good with writing a macro but I can record it very easily in IPP once the workflow is working, so could you please direct me to menu commands?

Thanks so much from now!

Daniel

Answers

  • edited August 2018
    2018-08-21-100440

    Daniel --

    I think you have most of the solution.

    I think the SECRET SAUCE that you may be unaware of is the SAVE OUTLINE and LOAD OUTLINES feature that is on the FILE MENU in the IPP7 COUNT SIZE DIALOG BOX as shown below.



    Below is a SCREEN CAPTURE that shows:

    -- Create an OBJECT in AAA
    -- Create MASK1 of the AAA OBJECT
    -- Dilate the MASK1 and create MASK2
    -- Create an OBJECT in MASK2
    -- Save the MASK2 OBJECT in an SCL FILE (using SAVE OUTLINES)
    -- Load the MASK2 OBJECT on the image in BBB

    Now the pixels under / within the MASK2 OBJECT in BBB can be measured.

    I hope this information is helpful.

    -- Matt

    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-



  • Hi there Matt!

    Thanks so much for your time!
    Well, I think I am loosing a step somewhere and the final measurement is not done only under my AOI:

    - I create a mask, I dilate it, select it based on histogram, count to generate the object, and then export outlines. On the original image I load the outlines: 


    - Then still on the original image I use a predefined color selection (saved as the RGB profile, it will be the same for all images) to highlight my green signal: 
    - The outline (mask) is not there anymore and if I select to measure area and density, it will measure everything and not only under my AOI:


    I think somehow the object outline is not considered an AOI in the end...
    Any thoughts on what am I doing wrong?
    Thanks so much again!!!
    Daniel
  • 2018-08-22-103215

    Daniel --

    I am not sure where your procedure is failing.

    I have created and worked with a couple of images that I think illustrate how an OUTLINES FILE can be moved from a MASK IMAGE into NON-MASK IMAGE and used to make a measurement.

    Notice that in the first data set the measurements were from the ACTUAL OBJECTS.  In the second data set the measurements were from the DILATED OBJECTS.

    I hope this information is helpful.

    -- Matt










  • Dear Matt,

    Please see a screen capture during the analysis (zip archive and inside a .webm movie).

    I am selecting first the RGB profile of the green signal, then I am drawing the AOI, convert it to object and save the outlines. Then I import the outlines and make the measurements on the green profile defined in the beginning. In the end the objects are through the image and not only under the AOI.

    What do you think now?

    THANKS BIG TIME!!!
    Daniel


  • 2018-08-22-163526

    Daniel --

    I think you are doing everything right up until 1:45.

    Pressing the COUNT BUTTON makes IPP find objects again.  You should be pressing the MEASURE BUTTON.

    In my IPP, there is a MEASURE BUTTON in the COUNT/SIZE BOX and within the SELECT MEASUREMENTS BOX. 



    You do not seem to have the MEASURE BUTTON in COUNT SIZE but if you have it within SELECT MEASUREMENTS, this is what you should press rather than the COUNT at this point in your procedure.

    If you do not have a MEASURE BUTTON in SELECT MEASUREMENTS, you can trigger a MEASURE with a macro.  The CODE is below.

    I hope this information is helpful.

    -- Matt

    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

    ' Default Script
    Option Explicit


    Sub fred()
        ret = IpBlbMeasure()
    End Sub


  • Dear Matt,

    I have tried to use Measure instead of Count but now I only have one measurement, the full AOI!

    Without this AOI, the green sampling tool selected a multitude of points in this region, so I am guessing the software does not use the color picker profile anymore, but just counts the average density and the full area of the AOI since I get only one measurement! Thus does it also count the red channel too because is a part of the RGB image below?

    Please, would you be so kind to upload a movie capture with your desktop during the exercise? I am attaching an image here for this purpose. So the idea is to draw around a red vessel, dilate the profile, but then analyze the green color in this dilated ROI, and not the red! If possible I would not extract the green channel and I would work on the full RGB image to see how the algorithm is working!

    Thanks so much for everything and please excuse me for my clumsiness :-)))

    All the best,
    Daniel

  • 2018-08-24-101529

    Daniel --

    Please see IMAGE below and ZIP FILE attached.

    I hope this information is helpful.

    -- Matt


    AAA = ORIGINAL IMAGE
    BBB = MASK OF GREEN THRESHOLD ON AAA
    CCC = RED THRESHOLD ON AAA WITH SMOOTHING AT 20 PLUS COUNT PLUS FILTER OUT SMALL OBJECTS
    DDD = MASK OF OBJECTS FROM CCC
    EEE = DILATION OF DDD (Watch out because the DILATION you chose seems to skew down and to the right).
    FFF = BBB ANDED WITH DDD PLUS BRIGHT THRESHOLD PLUS COUNT
    GGG = AAA PLUS OUTLINES FROM FFF
    MEASUREMENT DATA = GGG PLUS MEASURE
Sign In or Register to comment.