Quick ROI Question

Hi All,

I am very new to ImageJ and developing macros, and the extent of my experience is my familiarization with the User Guide and introduction to macros and built in macro functions. I asked this question at the end of my previous post, but the answer I received just directed me to the User Guide. I was wondering if anyone could answer this question I have and provide guidance on developing the macro that is more than just a URL to the User Guide:

How can I have a user draw an ROI (like draw a rectangle in a certain region of one of those sample images I uploaded) and then find the edges based on that ROI? I would then want to output those x coordinates of the edges into a text file.

I would appreciate any help that is specific to the functions and the thought process behind selecting the functions when creating a macro for this.

Thank you all very much!

I should also add that the basis for an edge for the images I am particularly looking at constitute a difference between a light and dark spot (e.g a dark rectangle and right next to is a light rectangle, so the edge position would be the boundary between the two rectangles). I am curious to learn about any ideas of automatically detecting the edges between the light and dark regions. One poster mentioned applying a vertical projection of the image’s bandpass-filtered version, but I was wondering if there are any other thoughts on this problem, as I have no idea how I would program the aforementioned idea.

It would be easier for other users if you provided a link to the other thread.

So what you want to do is have the user select and ROI and then identify all edges that have a presence in that ROI (whether or not the edge is contained in the ROI or not). By edge you mean an area of high contrast. Is that correct?

Hi Andrew,

Thanks for the response. The link to the other thread is:

If you look at the other thread, there are sample images uploaded. In those images, the edge would constitute the border between the light and dark rectangles. Thank you!

Well, it seems like you already have a way to find the edges in a given image. As such, you could just get the bounding box of the ROI, crop to that, run the edge-finding code, and then adjust the output to account for the position of the ROI.

The only issue is that the edge-finding code does not account for the differences between the light and dark regions.