Closed kklmn closed 2 years ago
I think there is 2 ways for you to implement such think, depending on what you want to do.
1) You can create your own ROI profile, if you want to integrate that in the silx profile tools
See for example, examples/plotProfile.py
, but there is not much things inside.
You can take a look at:
silx/gui/plot/tools/profile/rois.py
which provides a set of dedicated ROIs to process profilesArcRoi
which can be used.ProfileRoiMixIn
. That's a way to put together a ROI and a processing (computeProfile
)This provides a lot of flexibility, but but have to work with the silx "profile" API.
2) If you need more freedom, or you want to handle it on your own:
You can take a look at examples/plotInteractiveImageROI.py
Thanks @vallsv! This is a good start.
Hi @vallsv,
By now I've figured out how to use ArcROI in my tools.
I notice that at large radii the arc gets segmented as shown here: Here I've quite strongly zoomed horizontally. My images have lines that are also very weakly curved, so large radii will be very usual for me. Can the roi shape be plotted smoother? Where this can be controlled?
Could you send to us the parameters of your ROI? It's kind of weird, i can't figure out how it could render such shape.
Basically, there is a polygonization done inside the ROI. Looking at the code it looks to be fixed by a point every 0.1deg.
https://github.com/silx-kit/silx/blob/master/src/silx/gui/plot/items/_arc_roi.py#L638
At this stage it's difficult to compute something depending on the actual plot zoom, and for now we dont have real circle/arc primitives, so we have to find a compromise as a nice fixed value.
The actual state is kind of bad, but we can improve it with a minimum fixed number of points, for example 100
# delta = 0.1 if geometry.endAngle >= geometry.startAngle else -0.1
sign = numpy.sign(geometry.endAngle - geometry.startAngle)
delta = min(0.1, abs((geometry.startAngle - geometry.endAngle) / 100) * sign
Maybe other parameters like the radius could be used to get a better result, i can't tell. You have maybe a better idea?
What do you think @t20100?
I start from the example plotInteractiveImageROI.py. Instead of RectangleROI I use:
plot.setKeepDataAspectRatio(False)
roi = ArcROI()
roi.setGeometry(center=(-3570, 505), innerRadius=3900, outerRadius=3915,
startAngle=-0.13, endAngle=0.13)
Then zoom the roi, but already on the big picture the segmentation is visible.
Yes, probably to give a reasonable number of points, like 100, would be a good solution.
Here is with my patch
I think the patch is good enough to be integrated as it is, ill just double check with my colleagues first.
@vallsv , it sounds good to me
Thanks again!
Dear silx creators,
I need a profile tool that integrates a 2D image along a circular arc. I imagine 3 handles visible on the image plot that define the arc and a SpinBox that sets the width. Can you please advise on where to start (to find good parent classes) about the following aspects:
Thank you very much in advance!