 # How to create a figure (e.g. circle) based on gray value plot profile?

I have this gray value plot generated from a line I traced from the middle of an image to the exterior (x axis is distance from the center of a circle). Is there a way I can create a new circle filled with the gray value at each distance from the center?
Thanks.

Hello,

There is always a way with a macro This macro is a work in progress but it makes circles and shows them on the ROI Manager

``````roiManager("reset");

values = getProfile();

getSelectionCoordinates(xpoints, ypoints);

cx = xpoints
cy = ypoints

for ( i = 0; i < values.length; i++ ) {
idx = values.length - i;
r = idx+1;
// Make circle from outside to inside
makeOval(cx-r, cy-r, 2*r, 2*r);
value = toHex(values[i]);
Roi.setFillColor(value+value+value);

}
roiManager("show all without labels");
``````
3 Likes

The solution proposed by @oburri is certainly the more flexible solution and illustrates nicely how to access the values from the profile.

For the special case of a circle created from a line profile, you can also take another approach:

• Extract/duplicate the line profile as a 1-dimensional image (using Edit › Selection › Straighten… with a line width of one)
• Expand your image in the second (i.e. `y`-) dimension to be a square
• Do a polar transform, e.g. with the help of the Polar Transformer plugin

Here’s a macro illustrating the process:

``````run("Straighten...", "title=line line=1");
size = getWidth();
run("Size...", "width=&size height=&size depth=1 average interpolation=None");
run("Polar Transformer", "method=Cartesian degrees=360 default_center for_polar_transforms,");
``````

And that’s how the result looks (for the given line selection on the Tree Rings sample image):  3 Likes