Adding contours in AstroImageJ

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding contours in AstroImageJ

cduston
I am interested in adding contours to an image using AstroImageJ. I was able to get some partial functionality by downloading the ContourPlotter plugin for ImageJ, but after smoothing the image the contours appear and immediately disappear. It's quite an old plugin, and may be failing due to a reason discussed here.

So, what is a good way to add contours to astronomical images using AstroImageJ?

(I have asked a similar question at the ImageJ Forum as well).
Reply | Threaded
Open this post in threaded view
|

Re: Adding contours in AstroImageJ

karenacollins
Administrator
I can duplicate the problem you see, but don't have a near-term fix. However, contour plots would be very useful for AIJ users, so I have added this feature request to the higher priority development queue.

I did find a near-term clunky work-around though. Using the contour plotter plugin you mentioned from here:
https://imagej.nih.gov/ij/plugins/contour-plotter.html

Using the "set as ROI" button next to each contour, one by one add each contour as an ROI and use AIJ_Toolbar=>Image=>Overlay=>Add Selection to add the contour to the ROI manager. Each contour will all unfortunately be added as a yellow contour. But, you can use AIJ_Toolbar=>Image=>Overlay=>To_ROI_Manger=>Properties to change each of the colors in the ROI manager.

The upside down numbers in the image below appeared at some point, but maybe that was an anomaly.

This is an overly cumbersome process, so clearly an updated tool needs to be implemented and supported for AIJ.

Karen



On 6/1/2020 4:57 PM, cduston [via AstroImageJ] wrote:
I am interested in adding contours to an image using AstroImageJ. I was able to get some partial functionality by downloading the ContourPlotter plugin for ImageJ, but after smoothing the image the contours appear and immediately disappear. It's quite an old plugin, and may be failing due to a reason discussed here.

So, what is a good way to add contours to astronomical images using AstroImageJ?

(I have asked a similar question at the ImageJ Forum as well).


If you reply to this email, your message will be added to the discussion below:
http://astroimagej.1065399.n5.nabble.com/Adding-contours-in-AstroImageJ-tp1360.html
To start a new topic under AstroImageJ, email [hidden email]
To unsubscribe from AstroImageJ, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Adding contours in AstroImageJ

cduston
I appreciate the attention to this issue - I can use the process you've provided to get my contours, but I also think a good solution in AIJ would be beneficial to more people then just me.

Over at the main ImageJ forums I was referred to a more updated plugin, ContourLines, which looks great, but I can't get to run properly. I'm going to continue the conversation over there, but perhaps that can be the basis for the added feature.

I also wanted to say, in case development happens, I was planning on measuring the sizes of the ROIs, so it would be good if that was built-in.

Thanks again for your attention to this - I would really like to keep this inside AIJ (rather then heading to Astropy or something), because it's a student project and AIJ is already such a great user-friendly system for my student researchers.
Reply | Threaded
Open this post in threaded view
|

Re: Adding contours in AstroImageJ

karenacollins
Administrator
I also tried the ContourLines plugin and got errors as well. It looks like the plugin maybe assumes it is in the fiji build, but I didn't have time to dig deeper. I'll start with this code when I get a change to see if I can get working.

Does the ContourLines plugin also fail in standard ImageJ? I haven't had time to test that either.

Karen

On 6/2/2020 4:07 PM, cduston [via AstroImageJ] wrote:
I appreciate the attention to this issue - I can use the process you've provided to get my contours, but I also think a good solution in AIJ would be beneficial to more people then just me.

Over at the main ImageJ forums I was referred to a more updated plugin, ContourLines, which looks great, but I can't get to run properly. I'm going to continue the conversation over there, but perhaps that can be the basis for the added feature.

I also wanted to say, in case development happens, I was planning on measuring the sizes of the ROIs, so it would be good if that was built-in.

Thanks again for your attention to this - I would really like to keep this inside AIJ (rather then heading to Astropy or something), because it's a student project and AIJ is already such a great user-friendly system for my student researchers.


If you reply to this email, your message will be added to the discussion below:
http://astroimagej.1065399.n5.nabble.com/Adding-contours-in-AstroImageJ-tp1360p1362.html
To start a new topic under AstroImageJ, email [hidden email]
To unsubscribe from AstroImageJ, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Adding contours in AstroImageJ

karenacollins
Administrator
In reply to this post by cduston
I decided to go ahead and look into getting the ContourLines functionality working in AIJ. I had to bring some new functionality from later version of ImageJ into AIJ, but it is now working as a built-in function in the Image_Display=>Analyze menus. The free-standing plugin may still not work, but the functionality is now in the latest AIJ daily build (the versions should show 3.4.0.14 or later after update).

To me, the feature is very tricky to use, and the coloring is highly sensitive to the contrast setting in the histogram when the code is executed. However, I was able to achieve the contours shown below with the settings shown below.

You may need to change the contrast to an undesired level to achieve the colors you want, and then change the contrast back to the level you want before saving the image.

I noticed that if some of the settings are too low (e.g. the smoothing radius=0 or 1), then it can hang AIJ.

If you find nice settings that seem to work, I'm sure the AIJ user base would appreciate any hints you can provide on this thread.

Karen










Reply | Threaded
Open this post in threaded view
|

Re: Adding contours in AstroImageJ

cduston
This is awesome - I've got it up an running now. Just to note, I had to delete the non-functional plugins from my AstroImageJ directory before it worked.

And you're right, the function is very sensitive to the parameters you pass to it. At low smoothing radius (less then 2, as you indicated), the function stalls AIJ. In addition if you use line integration steps that are too large (above around 0.05 for this image) you get "kinks" in the contours. Also, I'm not entirely sure I understand how the last two parameters ("Distance between lines" and "Stop line....") interact with each other.

But in any case, I am very thankful for your quick work here, and this might even be enough for what we need to do.
Reply | Threaded
Open this post in threaded view
|

Re: Adding contours in AstroImageJ

cduston
In reply to this post by karenacollins
I've made some progress here - a got a group of students to produce a plugin that does exactly what I want, and is far more stable then the two we've been discussing here. It does not produce regions, but rather a colored image with the contours overlayed. Perhaps what they've done already can be extended to produce regions instead, if that's a preferred feature. I am mostly interested in the ability to measure the areas of each contour region, which they have implemented in a simple way.

Anyway, a description can be found on our group's website: https://sites.google.com/merrimack.edu/mcarg/software, and I put the code on Github if anyone is interested in expanded on it: https://github.com/cduston44/ContourLineandAreaMeasurement.

(I also developed a simple Jupyter/AstroPy notebook to perform the contour lines. The results are a bit nicer, but I didn't get to the area measurements. Check that out here: https://github.com/cduston44/AstroPyContours)