Author Topic: Effect of void pcl::ImageGeometry::SelectRectangle ( int x0, ...)  (Read 4214 times)

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Hi,

I am wondering about the exact effect of void pcl::ImageGeometry::SelectRectangle().
- Suppose I have an Image with width 4711 and height 3333
- Image coordinates as used by PixelData run from 0..4710 for x and 0...3332 for y
- If I set  pcl::ImageGeometry::SelectRectangle(100,200,300,400), which pixel range will be affected in subsequent calls of Apply():
  1. x in range 100..299, y in range 200..399?
  2. x in range 101..300, y in range 201..400?
  3. x in tange 100..300, y in range 200..400?
I am asking because I find that  pcl::ImageGeometry::ResetSelection() would reset to range selected.rectangle.Set( 0, 0, width, height ), which assuming option 3 would be one pixel more in each direction than the image really has...

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
I would say that it is the first option. See how it is used in the HDRC code to perform padding.
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Rectangles of integer coordinates exclude the bottom right corner in PixInsight/PCL/PJSR. This means that a rectangle with coordinates:

x0 = 100
y0 = 200
x1 = 300
y1 = 400

defines the rectangular region from {100,200} to {299,399} both points included. The row at y=400 and the column at x=300 are both excluded.

The advantage of this convention is that the width and height of a rectangle are equal to x1-x0 and y1-y0, respectively.

Note that for rectangles of real coordinates the same rule applies, but the bottom right corner is always included. This is just a consequence of the continuous nature of real coordinates, as opposed to the discrete nature of integer coordinates.

On the other hand, note that GenericRectangle's coordinate constructor is:

template <typename T, typename T1>
GenericRectangle<T>::GenericRectangle( T1 left, T1 top, T1 right, T1 bottom );


that is, it doesn't take width and height arguments, but four coordinate arguments. There is a constructor from two dimensions, namely:

template <typename T>
GenericRectangle<T>::GenericRectangle( T width, T height );


which creates a rectangle where x0=y0=0, x1=width and y1=height, that is, a rectangle anchored at the origin.


« Last Edit: 2011 June 18 13:48:08 by Juan Conejero »
Juan Conejero
PixInsight Development Team
http://pixinsight.com/