Author Topic: image width function in PixelMath  (Read 231 times)

Offline STEVE333

  • PixInsight Addict
  • ***
  • Posts: 200
    • View Profile
    • sk-images
image width function in PixelMath
« on: 2019 February 28 19:05:06 »
Is there a function in PixelMath that finds the width of an image?

If yes, how is it used?

Steve
Telescopes:  WO Star71 ii, ES ED102 CF
Camera:  Canon T3 (modified)
Filters:  IDAS LPS-D1, Triad Tri-Band, STC Duo-Narrowband
Mount:  CEM40 EC
Software:  BYEOS, PHD2, PixInsight
http://www.SteveKing.Pictures/

Offline ngc1535

  • PixInsight Addict
  • ***
  • Posts: 248
    • View Profile
Re: image width function in PixelMath
« Reply #1 on: 2019 February 28 19:53:28 »
Hmmm...
You can specify a dimension of the image by using X() in the normalized 0-1 sense.
So if you want something to happen at the halfway point across an image in the x-axis direction- you can say iif(X()==.5,then do something, or something else)

rdist() apparently returns distance to an arbitrary point. There might be a clever way to use it...

-adam

Offline STEVE333

  • PixInsight Addict
  • ***
  • Posts: 200
    • View Profile
    • sk-images
Re: image width function in PixelMath
« Reply #2 on: 2019 February 28 20:29:09 »
Thanks adam -

I was using

1 - x()/4216  where 4216 was the measured picture width.

Now I just use

 1-X()

Much cleaner.

Appreciate the help.

Steve
Telescopes:  WO Star71 ii, ES ED102 CF
Camera:  Canon T3 (modified)
Filters:  IDAS LPS-D1, Triad Tri-Band, STC Duo-Narrowband
Mount:  CEM40 EC
Software:  BYEOS, PHD2, PixInsight
http://www.SteveKing.Pictures/

Offline ngc1535

  • PixInsight Addict
  • ***
  • Posts: 248
    • View Profile
Re: image width function in PixelMath
« Reply #3 on: 2019 February 28 20:58:42 »
Thanks adam -

I was using

1 - x()/4216  where 4216 was the measured picture width.

Now I just use

 1-X()

Much cleaner.

Appreciate the help.

Steve

Ha! I said something *useful*... excellent! I thought about deleting my comment since it really isn't returning an actual image dimension... but most times you do not need the literal value with the normalized version.

Offline STEVE333

  • PixInsight Addict
  • ***
  • Posts: 200
    • View Profile
    • sk-images
Re: image width function in PixelMath
« Reply #4 on: 2019 February 28 21:17:52 »
Hey!!

It was more than useful - It was perfect!!!

Well done.

Steve
Telescopes:  WO Star71 ii, ES ED102 CF
Camera:  Canon T3 (modified)
Filters:  IDAS LPS-D1, Triad Tri-Band, STC Duo-Narrowband
Mount:  CEM40 EC
Software:  BYEOS, PHD2, PixInsight
http://www.SteveKing.Pictures/

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 6619
    • View Profile
    • http://pixinsight.com/
Re: image width function in PixelMath
« Reply #5 on: 2019 March 01 01:52:35 »
Working with normalized coordinates is convenient when you want to make your PixelMath expressions independent on specific image properties.

You can also work in pixels. Excerpted from the function documentation provided in the Expression Editor dialog:


w( [image=$T] )

   Width in pixels of an image (invariant subexpression).

h( [image=$T] )

   Height in pixels of an image (invariant subexpression).

x()

   Current horizontal (X-axis) coordinate in integer pixels.

y()

   Current vertical (Y-axis) coordinate in integer pixels.


Note that PixelMath is case-sensitive, so x() and X() are different functions (the latter evaluates to the current X-axis coordinate normalized to [0,1]). Note also that in formal documentation descriptions (metalanguage), square brackets denote optional items. So you can say just w() and it will be equivalent to w( $T ). Or you can say w( foo ) to get the width in pixels of an image with the foo identifier.

For completeness, here are the corresponding functions for normalized coordinates:


X()

   Current normalized horizontal (X-axis) coordinate, in the [0,1] range.

Y()

   Current normalized vertical (Y-axis) coordinate, in the [0,1] range.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline STEVE333

  • PixInsight Addict
  • ***
  • Posts: 200
    • View Profile
    • sk-images
Re: image width function in PixelMath
« Reply #6 on: 2019 March 01 07:51:17 »
Thanks Juan - Very clear explanation.

Steve
Telescopes:  WO Star71 ii, ES ED102 CF
Camera:  Canon T3 (modified)
Filters:  IDAS LPS-D1, Triad Tri-Band, STC Duo-Narrowband
Mount:  CEM40 EC
Software:  BYEOS, PHD2, PixInsight
http://www.SteveKing.Pictures/