I have an MR image of a knee.
I want to apply a gradient filter locally so that if I click on a pixel, for example, say on any part of the femur, I'll be able to choose a circular or rectangular region of interest dynamically, on which the gradient filter will be applied.
Is it possible to do so?
Thanks a lot for the answer from bill s.
I've made one modification to his code for my specific purpose to apply a threshold to the gradient.
dims = ImageDimensions[img];
Manipulate[grad = GradientFilter[img, size] // ImageAdjust;
loc = MousePosition["GraphicsAbsolute", None];
mask = Graphics[Disk[loc, radius],
PlotRange -> Transpose[{{0, 0}, dims}], ImageSize -> dims];
maskedImage = SetAlphaChannel[img, Image[mask]];
Show[grad, maskedImage], {size, 2, 30}, {{radius, 30}, 1, 200}]
And here is the screenshot of the output:
Now suppose, I want to select and highlight the femur by applying suitable values for the size and radius and make all other parts transparent (as it can be done here). To do this I need to choose the nearest gradient peaks along all directions from the position of the mouse, so that I can create the desired boundary and thus the binary mask to select the region of interest.
A region growing or watershed transformation may be applied as explained in this video:
https://www.youtube.com/watch?v=s1ot5MltxM8&spfreload=1
How can I do so?