Re: ROI Scaling [message #55041] |
Tue, 31 July 2007 09:49  |
Dick Jackson
Messages: 347 Registered: August 1998
|
Senior Member |
|
|
"Erik" <janssen.e@gmail.com> wrote in message
news:1185887600.007960.156080@o61g2000hsh.googlegroups.com.. .
> Hi folks,
>
> I run into a small problem when scaling a IDLgrROI object. I want the
> ROI to stretch out so that it's slightly bigger. I'm using the SCALE
> function to achieve this:
>
> oRoi->Scale, [1.5,1.5]
>
> The scale function does what it promised; the ROI grows bigger.
> Unfortunately the position of the ROI gets messed up and the ROI moves
> upwards or even out of screen. Does someone know what causes this? I
> can't find more info or parameters in IDL's helpfile ;-)
The help file says "The IDLanROI::Scale procedure method modifies the vertices
for the region by applying a scale." To be more clear, that means that all your
X and Y values are scaled by simple multiplication. If your ROI were centered
around [0,0] it would work as (I think) you expect, and it would stay "in place"
and change in size.
To scale in place, try something like this:
;; Find 'centre' for scaling
oROI->GetProperty, ROI_XRange=xr, ROI_YRange=yr
midX = Mean(xr)
midY = Mean(yr)
;; Shift ROI to surround [0,0]
oROI->Translate, -midX, -midY
;; Scale ROI
oRoi->Scale, [1.5,1.5]
;; Shift ROI back
oROI->Translate, midX, midY
Hope this helps!
--
Cheers,
-Dick
--
Dick Jackson Software Consulting http://www.d-jackson.com
Victoria, BC, Canada +1-250-220-6117 dick@d-jackson.com
|
|
|
Re: ROI Scaling [message #55179 is a reply to message #55041] |
Thu, 02 August 2007 02:27  |
Erik[1]
Messages: 23 Registered: December 2006
|
Junior Member |
|
|
On 31 jul, 18:49, "Dick Jackson" <d...@d-jackson.com> wrote:
> "Erik" <jansse...@gmail.com> wrote in message
>
> news:1185887600.007960.156080@o61g2000hsh.googlegroups.com.. .
>
>> Hi folks,
>
>> I run into a small problem when scaling a IDLgrROI object. I want the
>> ROI to stretch out so that it's slightly bigger. I'm using the SCALE
>> function to achieve this:
>
>> oRoi->Scale, [1.5,1.5]
>
>> The scale function does what it promised; the ROI grows bigger.
>> Unfortunately the position of the ROI gets messed up and the ROI moves
>> upwards or even out of screen. Does someone know what causes this? I
>> can't find more info or parameters in IDL's helpfile ;-)
>
> The help file says "The IDLanROI::Scale procedure method modifies the vertices
> for the region by applying a scale." To be more clear, that means that all your
> X and Y values are scaled by simple multiplication. If your ROI were centered
> around [0,0] it would work as (I think) you expect, and it would stay "in place"
> and change in size.
>
> To scale in place, try something like this:
>
> ;; Find 'centre' for scaling
> oROI->GetProperty, ROI_XRange=xr, ROI_YRange=yr
> midX = Mean(xr)
> midY = Mean(yr)
>
> ;; Shift ROI to surround [0,0]
> oROI->Translate, -midX, -midY
>
> ;; Scale ROI
> oRoi->Scale, [1.5,1.5]
>
> ;; Shift ROI back
> oROI->Translate, midX, midY
>
> Hope this helps!
>
> --
> Cheers,
> -Dick
>
> --
> Dick Jackson Software Consulting http://www.d-jackson.com
> Victoria, BC, Canada +1-250-220-6117 d...@d-jackson.com
Hi Dick,
Thanks for your answer. It seems that you are right about the vertices
and the translate function solved the problem for me. My understanding
of IDL's logic and math sometimes is a bit messy so thanks for
clearing this up ;-)
Regards,
Erik
|
|
|