Re: Macro question: test if a point is within selection/ROI
Posted by
Jonathan Jackson-2 on
Mar 12, 2008; 12:51pm
URL: http://imagej.273.s1.nabble.com/Macro-question-test-if-a-point-is-within-selection-ROI-tp3696899p3696904.html
On Wed, 12 Mar 2008 00:24:22 -0400, Rasband Wayne <
[hidden email]> wrote:
>> Is it possible, in a macro, to find out if a given point lies
>> within the current selection / ROI. I'm writing a macro to
>> alter the intensity of pixels within the selection, but can't
>> figure out how to do this!
>>
>> I've looked at getSelectionBounds and getSelectionCoordinates
>> but so far as I can't see a simple way to go from these to the
>> coordinates of pixels within the region.
>
>You can add a value to all the pixels in the selection using
>
> run("Add...", "value="+value);
>
>or multiply using
>
> run("Multiply...", "value="+value);
>
>Use
>
> setColor(value);
> fill;
>
>to set the pixels in the selection to a specified value.
>
>-wayne
>=========================================================================
Thanks for the reply. The operation I had in mind was to set the pixels
within a selection to values with a given mean and standard deviation. This
could be done using existing macro commands and a run() call, as you
suggest, but it's important to have the option to 'undo' this macro (see
"Macro feature request: prevent calls to run() creating undo snapshots" ) so
I was trying to modify pixels in the selection directly from the macro. The
option to identify if a pixel is within the selection could potentially be
useful in other macro applications as well. I could write a plugin to
operate on the selection, but it would be nice to do it all in the macro
tool code.
thanks again,
Jon