| Class | RFits::ImageData |
| In: |
lib/rfits/rfits.rb
|
| Parent: | Object |
Represents the actual pixels in a FITS file.
| BITPIX_IMG_MAP | = | { IO::Proxy::BYTE_IMG => IO::Proxy::TBYTE, IO::Proxy::SHORT_IMG => IO::Proxy::TSHORT, IO::Proxy::LONG_IMG => IO::Proxy::TLONG, IO::Proxy::LONGLONG_IMG => IO::Proxy::TLONGLONG, IO::Proxy::FLOAT_IMG => IO::Proxy::TFLOAT, IO::Proxy::DOUBLE_IMG => IO::Proxy::TDOUBLE, IO::Proxy::SBYTE_IMG => IO::Proxy::TSBYTE, IO::Proxy::USHORT_IMG => IO::Proxy::TUSHORT, IO::Proxy::ULONG_IMG => IO::Proxy::TULONG |
| image | [R] | The image the data belongs to. |
An alias for ImageData#pixels, but automatically chooses the datatype for you based on the type of image (i.e. BITPIX).
An alias for ImageData#set_pixels, but automatically chooses the datatype for you based on the type of image (i.e. BITPIX).
Retrieve the ith (where i is zero-based) column of the image array. Assumes a two-dimensional image.
Retrieve the value of a pixel, or a range of pixels. The value is coerced into an appropriate class according to the datatype provided. Can be used in a number of ways. The simplest plucks the nth pixel from the image array:
image.data.pixels(IO::Proxy::TSHORT, 0) # first pixel in the image (remember zero-based indexing?) image.data.pixels(IO::Proxy::TSHORT, image.data[image.data.size - 1]) # last pixel in the image
You can also choose a range of contiguous pixels, in which case an array of values is returned:
image.data.pixels(IO::Proxy::TSHORT, 0..10) # retrieve first 10 pixels
or pick the single pixel at a particular coordinate:
image.data.pixels(IO::Proxy::TSHORT, 4, 5)
or equivalently:
image.data.pixels(IO::Proxy::TSHORT, [4, 5])
In addition, you can give an (x,y) coordinate and a number of pixels, assuming the coordinates are zero-based:
image.data.pixels(IO::Proxy::TSHORT, [4, 5], 10) # 10 pixels starting at the point [4, 5]
or get all the pixels between two points:
image.data.pixels(IO::Proxy::TSHORT, [4, 5], [6, 6]) # all the pixels between the points [4, 5] and [6, 6]
Retrieve the ith (where i is zero-based) row of the image array. Assumes a two-dimensional image.
Set the value of a pixel, or a range of pixels. The value is coerced into an appropriate class according to the datatype provided. Can be used in a number of ways. The simplest sets the nth pixel in the image array:
image.data.set_pixels(IO::Proxy::TSHORT, 0, 5) # first pixel in the image is set to 5
You can also set a range of contiguous pixels:
image.data.set_pixels(IO::Proxy::TSHORT, 0..10, [5, 5, 3, 1, 0, 9, 5, 6, 7, 1]) # set first 10 pixels
or set the single pixel at a particular coordinate:
image.data.set_pixels(IO::Proxy::TSHORT, 4, 5, 10) # set pixel at [4, 5] to 10
or equivalently:
image.data.set_pixels(IO::Proxy::TSHORT, [4, 5], 10)
In addition, you can give an (x,y) coordinate and a list of pixels, assuming the coordinates are zero-based:
image.data.set_pixels(IO::Proxy::TSHORT, [4, 5], [1, 2, 3, 4]) # four pixels with values 1, 2, 3, 4 starting at [4, 5]
or set the pixels between two points:
image.data.set_pixels(IO::Proxy::TSHORT, [0, 0], [1, 1], [5, 6, 7, 8]) # set pixels to (5, 6, 7, 8) between [0, 0] and [1, 1]