Closed amarzullo24 closed 10 years ago
The slice() method on the MINC volume object returns an object that can get you the information you want: the data property contains the intensity values, and the getImage() method will return an array of those intensities mapped to RGB values. Be careful when using the image produced by getImage() though as it automatically performs a nearest neighbour interpolation, so you can't use the voxel positions directly with it. To get around this problem, you may want to map the colors in a manual step.
All that said, I think this operation should definitely be easier to do. I'll work on implementing a getIntensity() method for slices.
Thanks for the reply! At the moment I'm using the method to get the color from the canvas: "currentPanel.context.getImageData(cursorCoords[0],cursorCoords[1],1,1).data;" Do you think it returns the same colors or it could be different?
and what about currentPanel.slice_image.data? is it the array you are talking about?
Do you think it returns the same colors or it could be different?
Looking at the canvas' pixel values will get you the color that is display on the screen, but not the value stored in the MINC image.
If the canvas displays two images overlayed on top of each other, then the color you will get back is not the same color that is stored on the image. The color you get back also depends on the color mapping and the nearest neighbor interpolation. so it might not be relevant to look at the ImageObject
returned by .getImageData()
…
If you just need the colour at a pixel, your approach should work @AldoMarzullo. @PaulMougel is right, though, that you probably won't be able to map this colour back to an intensity value.
I'm working on two methods getIntensityValue(x, y, z) for volumes and colourFromValue(val) for color map objects that I think will make all this easier.
In order to understand better what I need: I'm implementing a segmentation tool based on the floodfill algorithm; Starting from the point where I click, I get all contiguous point which have the same color. (I'm working with the gray scale colormap) Thanks for your help
If you really just need the colour, Aldo, your approach might be enough.
I've committed the new methods I created to a branch on my fork, if you want to take a look at them: 56193741342fe69c78c2d201ad5e1752bb639912.
To give you an idea how they work, you would get the intensity value at a location with this code:
var value = volume.getIntensityValue(x, y, z, time);
It will default to the current position if you don't pass arguments. To convert the value to a colour, you'd use the following:
var color = color_map.colorFromValue(value);
Ok, the new methods are now merged to master (739819839171fe6a36707d49df63d87cfe5f76f6). Check them out and let me know if they help.
Ok, they work fine! Thank you a lot!
I'm working on the volume viewer; I got the voxel coordinates of the point where I click and now I need to know what is the value of the color in this point. I studied the code and in particular in minc.js file, I found a lot of variables and array ("data" for example), but I'm not sure if they will get me what I want.. is there any way to get this value using the voxel coords or I have to use the "classic" canvas method?