Greetings and thank you for taking the time to read this!
This query is closely linked to the following library: https://github.com/FNNDSC/ami
I am interested in developing a function that can detect when a user clicks on a segment within an image, triggering a dialog box with relevant information.
After searching on my own and consulting examples on StackOverflow, I have managed to establish a rudimentary method to detect the location of a click and determine if it falls within a specific segment:
window.addEventListener('click', onWindowClick, false);
function onWindowClick(event) {
if (event.clientX > 200 && event.clientX < 300) {
alert('You have clicked: ' + event.clientX + " " + event.clientY + ' within the segment');
} else {
alert('You have clicked: ' + event.clientX + " " + event.clientY + ' outside the segment');
}
For instance, clicking near the green area would yield the following output: https://i.sstatic.net/1yFSb.png
Clicking outside would result in: https://i.sstatic.net/dBg22.png
The main dilemma is: what specific data or positional resources are needed to accurately determine if a click falls within the segment?
Upon closer inspection, it seems that there are two viable options within the data structure. Firstly, we could utilize the frame's position, which appears to represent the spatial location of the segmentation in the form of: https://i.sstatic.net/5W7Xw.png
Specifying the clicked position as: 277 294
and the _imagePosition from the data structure as: -201 -59
Alternatively, another feasible option is the stack's origin: https://i.sstatic.net/f1WdL.png
With the clicked position as: 278 301
and the origin denoted as: -201 -59
Evidently, whether opting for _imagePosition or the stack's origin, some form of conversion would be required.
Having conducted further research, it is apparent that ijk and lps coordinate systems are employed, often necessitating the usage of a matrix for seamless conversion between the two.
If you have any recommendations or assistance to offer, they would be greatly appreciated! Thank you!