How to get Random ROI in defined region and use "analyze particles" ?

Hello everyone, I am attempt to create a macro for my image analysis but so

far I couldn’t figure out how to combine the functions I desire in a macro.

I have a tissue slice stained by antibody and I want to have certain amount

of ROIs in the defined region (inside the blue line) (like the figure showed

below) then allow me to use “analyse particles” for further analyze.

Is there a way to do this?

Actually I found some macros that someone wrote, but that only have one of

the functions I desire and I fail to combine those functions.

Thank you.

Hi @Ajuju,

Could you precise a little bit your mind. You are looking to draw a ROI (which shape ?) that is all included inside the blue line ?

Nico

hi @VirtualSlide
So sorry that I don’t make myself clear.
I mean I will draw a irregular shape of ROI (which is the blue line) and I want to randomly select some new ROIs inside this area, that’s say I get 10 ROIs inside the blue line area, for these 10 new ROIs I want to perform “analyze particles” for each of these 10 new ROIs to get the particles area of each box.

There is several options.
You can play with Roi.getContainedPoints(xpoints, ypoints) and check if every point of the new ROi is contained in the blue line one.
You can also create a mask of the bue line ROI, filled with a constant value (say 255) and measure the min intensity of the new ROI in this mask (255, it is all contained inside ; 0, at least one point is outside).

And of course to get the coordinates of your random ROI, you will use random function (*size of your image)

Nico

Thank you for your instruction, the process end up well. :slight_smile: