I'm experiencing an issue with arrow annotations in my ImageDisplay component. When I create arrow annotations sequentially, the arrow coordinates are correct. However, if I first create an annotation group and then add arrow annotations to this group, the arrow coordinates become incorrect. It appears that the marker group's coordinate system might not match the coordinate system used by ImageDisplay.
What I've Tried:
- Generating arrow markers one by one works as expected.
Image img := RealImage("RImg",4,256,256)
img.ShowImage()
ImageDisplay img_disp = img.ImageGetImageDisplay(0)
ImageDocument img_doc = img.ImageGetOrCreateImageDocument()
Number radius = 50
Number cx = 128
Number cy = 128
Number flag = 1
for (Number count = 0 ; count < 4 ; count++)
{
Number phi = count * 2 * Pi()/ 4
Number px = round(cx+radius*Cos(phi))
Number py = round(cy+radius*Sin(phi))
Component arrow = NewArrowAnnotation(cy, cx, py, px)
img_disp.ComponentAddChildAtEnd(arrow)
}
- Creating a marker group first and then adding arrow markers leads to mixed-up coordinates.
Image img := RealImage("RImg",4,256,256)
img.ShowImage()
ImageDisplay img_disp = img.ImageGetImageDisplay(0)
ImageDocument img_doc = img.ImageGetOrCreateImageDocument()
Component arrows = NewGroupAnnotation()
Number radius = 50
Number cx = 128
Number cy = 128
for (Number count = 0 ; count < 4 ; count++)
{
Number phi = count * 2 * Pi()/ 4
Number px = round(cx+radius*Cos(phi))
Number py = round(cy+radius*Sin(phi))
Result(py + ", " + px + "\n")
Component arrow = NewArrowAnnotation(cy, cx, py, px)
arrows.ComponentAddChildAtEnd(arrow)
}
img_disp.ComponentAddChildAtEnd(arrows)
Questions:
- What could cause the coordinate discrepancy between the marker group and the ImageDisplay?
- How can I ensure that the marker group uses the same coordinate system as ImageDisplay when adding arrow markers?
I'm experiencing an issue with arrow annotations in my ImageDisplay component. When I create arrow annotations sequentially, the arrow coordinates are correct. However, if I first create an annotation group and then add arrow annotations to this group, the arrow coordinates become incorrect. It appears that the marker group's coordinate system might not match the coordinate system used by ImageDisplay.
What I've Tried:
- Generating arrow markers one by one works as expected.
Image img := RealImage("RImg",4,256,256)
img.ShowImage()
ImageDisplay img_disp = img.ImageGetImageDisplay(0)
ImageDocument img_doc = img.ImageGetOrCreateImageDocument()
Number radius = 50
Number cx = 128
Number cy = 128
Number flag = 1
for (Number count = 0 ; count < 4 ; count++)
{
Number phi = count * 2 * Pi()/ 4
Number px = round(cx+radius*Cos(phi))
Number py = round(cy+radius*Sin(phi))
Component arrow = NewArrowAnnotation(cy, cx, py, px)
img_disp.ComponentAddChildAtEnd(arrow)
}
- Creating a marker group first and then adding arrow markers leads to mixed-up coordinates.
Image img := RealImage("RImg",4,256,256)
img.ShowImage()
ImageDisplay img_disp = img.ImageGetImageDisplay(0)
ImageDocument img_doc = img.ImageGetOrCreateImageDocument()
Component arrows = NewGroupAnnotation()
Number radius = 50
Number cx = 128
Number cy = 128
for (Number count = 0 ; count < 4 ; count++)
{
Number phi = count * 2 * Pi()/ 4
Number px = round(cx+radius*Cos(phi))
Number py = round(cy+radius*Sin(phi))
Result(py + ", " + px + "\n")
Component arrow = NewArrowAnnotation(cy, cx, py, px)
arrows.ComponentAddChildAtEnd(arrow)
}
img_disp.ComponentAddChildAtEnd(arrows)
Questions:
- What could cause the coordinate discrepancy between the marker group and the ImageDisplay?
- How can I ensure that the marker group uses the same coordinate system as ImageDisplay when adding arrow markers?
1 Answer
Reset to default 2The details of how coordinate systems are inherited by child Components of various types are very unclear to me and I have not found any place in the DM documentation that fully spells this out. Perhaps someone else can point us to a clearer explanation.
However, it does seem to be clear that group annotations do not have a well-defined coordinate system of their own and thus adding new (previously unplaced) annotations to a group often does not yield the desired result. The better approach seems to be to first place new annotations on the desired ImageDisplay and then add such placed annotations to a group in order to achieved the desired association of daughter Components, as follows:
Number imgW = 256
Number imgH = 256
Image img := RealImage("RImg",4,imgW,imgH)
img.ShowImage()
ImageDisplay img_disp = img.ImageGetImageDisplay(0)
ImageDocument img_doc = img.ImageGetOrCreateImageDocument()
Component arrows = NewGroupAnnotation()
img_disp.ComponentAddChildAtEnd(arrows)
Number radius = 50
Number cx = imgW/2
Number cy = imgH/2
for (Number count = 0 ; count < 4 ; count++)
{
Number phi = count * 2 * Pi()/ 4
Number px = round(cx+radius*Cos(phi))
Number py = round(cy+radius*Sin(phi))
Component arrow = NewArrowAnnotation(cy, cx, py, px)
img_disp.ComponentAddChildAtEnd(arrow)
arrows.ComponentAddChildAtEnd(arrow)
}
TagGroup properties = NewTagGroup()
arrows.ComponentExternalizeProperties(properties)
properties.TagGroupOpenBrowserWindow(0)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745039754a4607739.html
评论列表(0条)