Author Topic: PixInsight shows pixel values as 0-1 floats but the FITS file contains 0-64K  (Read 14254 times)

Offline Nocturnal

  • PixInsight Jedi Council Member
  • *******
  • Posts: 2727
    • http://www.carpephoton.com
Hi,

I'm still struggling to make Envisage FITS files work properly with PCL. I used ds9 to load a FITS3P file and each channel uses values from 0 to 65335, stored as floats. When I load the same file in PCL and move my cursor the values shown are between 0 and 1. When I calculate pixel statistics I get values between 0 and 1. When I save the file, without making any changes, to the default FITS format (32 bit float) ds9 indeed shows values between 0 and 1 for each pixel.

Does PCL translate the pixel values? This came up in my recent thread about Envisage in-compatibility with PCL but it wasn't resolved so I wanted to start a new thread about this topic.

Thanks,

  Sander
Best,

    Sander
---
Edge HD 1100
QHY-8 for imaging, IMG0H mono for guiding, video cameras for occulations
ASI224, QHY5L-IIc
HyperStar3
WO-M110ED+FR-III/TRF-2008
Takahashi EM-400
PIxInsight, DeepSkyStacker, PHD, Nebulosity

Offline Nocturnal

  • PixInsight Jedi Council Member
  • *******
  • Posts: 2727
    • http://www.carpephoton.com
I meant '65535'  of course, sorry.

My concern is that when you adjust the values, effectively scaling them, you change the data. Histograms no longer make sense. I've zipped up two images, both 5 minute exposures, one cooled (about 5C) and the other 25C or so. When you load these in PCL you'll see the histogram on the cooled one is to the right of the uncooled one. That makes no sense. Image statistics show that the cooled image has *higher* average pixel values.

The images have the RANGE keyword set to 65535 which seems correct. What's the problem? What can I do to these FITS files to make them load correctly?

Thanks,

  Sander

http://www.tungstentech.com/files/twofits.zip
Best,

    Sander
---
Edge HD 1100
QHY-8 for imaging, IMG0H mono for guiding, video cameras for occulations
ASI224, QHY5L-IIc
HyperStar3
WO-M110ED+FR-III/TRF-2008
Takahashi EM-400
PIxInsight, DeepSkyStacker, PHD, Nebulosity

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Hi Sander

Just a note to avoid confusions. Readouts are given as you specify them with their own preferences. As defauls, PixInsight shows values in the normalizated range ( from 0 to 1). This is transparent and it doesn't matters the sample type. For example, load a 8bit jpeg image, and you'll see what I mean.

By the other hand, out of the normalizated range values may be readed too. For example, the current Divide process does not rescale data or clip out of range values, so if you are working with floating point images, you may see values greater than 1 (with integer images, due to overflow, they get dark values. For example, instead of 260, you'll get a value of 4).


So, I think that if the Range keyword is propperly readed, and data is transformed into the normalizated range (if there is data outside the Range setting, it will be clipped), new generated floating point images will store the values in the normalizated range. IMHO, this behavior is against the use of images as simple data storages... usefull for other fields in image processing... but I don't know for sure how the standards of the FITS format works, so this may be the correct way to manage data. Juan should clarify this topic...



Anyway, just as a suggestion... Is there any problems if you save the data as 16 bits integer images? Is there any data loss?
Regards,

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

Offline Nocturnal

  • PixInsight Jedi Council Member
  • *******
  • Posts: 2727
    • http://www.carpephoton.com
Hi Carlos,

thanks for replying. I would save in integer format but unfortunately the Envisage capture software does not store the unprocessed subs in that format, even when I tell it to. An annoying bug. I may buy a Nebulosity license to get around this but I'd also like to understand how PCL loads and represents these float files. It seems the range is determined by the min and max data found in the array rather than what the range keyword indicates.

I think that when possible PCL should leave the data format alone unless explicitly converted. The user perhaps had a reason why a particular format was used, we should probably keep using it. So when a pixel says '3245' I don't expect it to come back as 0.134. I'm curious what the rationale is. Image statistics would also be more useful if they used the file's native format.

As a side effect of the apparent scaling of the data if I now subtract a bias frame from a dark frame I get left with negative values. That's a little odd. Also my cooled image has a histogram that's quite a bit to the right compared to the uncooled image. Also strange.

Thanks,

   Sander
Best,

    Sander
---
Edge HD 1100
QHY-8 for imaging, IMG0H mono for guiding, video cameras for occulations
ASI224, QHY5L-IIc
HyperStar3
WO-M110ED+FR-III/TRF-2008
Takahashi EM-400
PIxInsight, DeepSkyStacker, PHD, Nebulosity

Offline Nocturnal

  • PixInsight Jedi Council Member
  • *******
  • Posts: 2727
    • http://www.carpephoton.com
As an FYI, PixInsight LE works the same way so there's probably a good reason for it but I sure don't understand it :-)
Best,

    Sander
---
Edge HD 1100
QHY-8 for imaging, IMG0H mono for guiding, video cameras for occulations
ASI224, QHY5L-IIc
HyperStar3
WO-M110ED+FR-III/TRF-2008
Takahashi EM-400
PIxInsight, DeepSkyStacker, PHD, Nebulosity

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Hi Sander,

Quote
The images have the RANGE keyword set to 65535 which seems correct. What's the problem? What can I do to these FITS files to make them load correctly?


The problem with Envisage is that it is writing invalid floating point FITS files: it writes BZERO and BSCALE keywords that do not represent the actual data range that is stored in the file. There's nothing we can do to solve this, other than patching the file to write the correct BSCALE value with a binary editor, as we did yesterday with KHexEdit.

Note that *invalid* has nothing to do with *standard*. A perfectly standard FITS file can still be invalid if one or more header keywords are inconsistent, as is the case here.

Quote
My concern is that when you adjust the values, effectively scaling them, you change the data.


PixInsight always stores pixel values in RAM in their native data types. This means that if you load an integer 8-bit image, for example, it will remain this way unless you explicitly change it (with the SampleFormatConversion process). So there is no "adjustment" of existing values. It's just the *representation* of the data which may be changed arbitrarily.

Quote
When I load the same file in PCL and move my cursor the values shown are between 0 and 1. When I calculate pixel statistics I get values between 0 and 1.


When you load a floating point FITS file, the corresponding support module will rescale all pixel values to the [0,1] range. Note that this is not a problem at all. In fact, we gain numerical accuracy by representing all values inside the [0,1] range.

Quote
When I save the file, without making any changes, to the default FITS format (32 bit float) ds9 indeed shows values between 0 and 1 for each pixel.


When you save a floating point FITS or TIFF file, the corresponding support modules will always write pixel samples in the [0,1] range. Hence, when PixInsight writes a floating point FITS, it always sets BZERO=0 and BSCALE=1. Again, note that you are not losing any information in this way; it's just a change of scale, as before. Of course, you always can save a FITS file in an integer format if you want, from 8 to 32 bits.

Quote
So when a pixel says '3245' I don't expect it to come back as 0.134. I'm curious what the rationale is. Image statistics would also be more useful if they used the file's native format.


With Edit > Readout Options you can select an arbitrary data type and range to represent readout values.

Anyway, it is very interesting to explain why PixInsight uses the [0,1] range to represent pixel values by default.

We must take into account that our platform supports seven data types:

8-bit, 16-bit and 32-bit integers
32-bit and 64-bit floating point reals
32-bit and 64-bit floating point complex

The PixInsight platform is able to store and manipulate all of those pixel sample types in a completely transparently way. That is, you don't have to know the actual data type used to store your image in memory: any process you apply to it will work the same way regardless of the actual data types (except roundoff errors inherent to each data type, of course).

To provide a consistent data representation for all supported data types, PixInsight adopts the normalized real range [0,1]. It has several important advantages; the main ones are:

- It is independent on the underlying data type. This means that we can represent any data range as [0,1]. Not only the currently supported types, but any type that we can support in the future.

- It allows for intuitive evaluation of relative signal intensities. For example, a value of 0.35 is very easy to understand as a 35% of the full available dynamic range. Contrarily, a value of 22938 has no meaning at all unless we take a hand calculator to learn that 22938/65536 is approximately equal to 0.35.

- It is an abstract (hence, elegant) representation. The fact that a device works in the [0,65535] range is just a consequence of its particular physical limitations. The normalized [0,1] range is not related to any underlying physical implementation.

- It allows for arbitrary precision. We can implement the normalized [0,1] range with 64-bit floating point numbers, or even with 128-bit numbers supported by modern SSE extensions if necessary. This allows us to represent all supported data types with the required accuracy.

I hope this will clarify some key points.

Quote
As a side effect of the apparent scaling of the data if I now subtract a bias frame from a dark frame I get left with negative values. That's a little odd.


Yes, you get negative values, but there's no problem at all with them. For example, if you perform the subtraction with PixelMath, the negative values will be handled transparently. Or you can disable both truncation and rescaling, and the resulting negative values will remain there. The negative values actually make a lot of sense: they fully represent what's happening with your data (a value x has been subtracted from y, where x > y).
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Nocturnal

  • PixInsight Jedi Council Member
  • *******
  • Posts: 2727
    • http://www.carpephoton.com
Hi Juan,

I replied yesterday that when I change the bscale to 65535 NOTHING happens. The file you sent back as fixed had all the data replaced with 0-1 values as if it had been loaded in PCL and subsequently saved. The patch is not sufficient.

Thanks,

   Sander
Best,

    Sander
---
Edge HD 1100
QHY-8 for imaging, IMG0H mono for guiding, video cameras for occulations
ASI224, QHY5L-IIc
HyperStar3
WO-M110ED+FR-III/TRF-2008
Takahashi EM-400
PIxInsight, DeepSkyStacker, PHD, Nebulosity

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Sander,

There's something I can do: add a couple controls to the standard FITS support module to specify the desired output range for floating point images. In this way you'll be able to write floating point FITS with the 0,65535 range.

let me play with the source code and I'll upload the modified module.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Hi Sander,

I have just uploaded a new version of the FITS module that solves this problem. Now you can specify an arbitrary range to write floating point FITS files (in the range -2^31 to +2^31) on the new FITS Format Options dialog.

Please refer to this thread on the Announcements section.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Nocturnal

  • PixInsight Jedi Council Member
  • *******
  • Posts: 2727
    • http://www.carpephoton.com
Hi Juan,

thanks for your efforts but I don't see how this helps. The primary issue is not the way PCL saves the data. The issue is how it reads the data. I had to investigate how pcl saves it because the 'fixed' datafile you made for me looked different than the one I provided.

In any case.

I tried the new save method. I loaded a FITS file with 32bit floats (0-64K). I then saved the file with a 16 bit range. The resulting file, when read by PCL, contains no image data. I suspect this is because the data is still 0-1 but the range is now 0-64K and therefore the data disappears in the noise.

I'm not sure how to proceed now. I can't get you to understand how important it is to preserve the 0-64K dynamic range of the images PCL loads. If I load 2 images, both with 16 bit range and both contain a pixel with value 1000 BOTH images should contain the same pixel with 1000 or at least 1000/65535 if you insist on modifying the data you read to the internal scale. If PCL doesn't do this it's pointless to use it for pixel math, channel combination and other operations that involve multiple files.

Here are three more files:

http://www.tungstentech.com/files/pcl-lastone.zip

A 1s dark exposure and a 4m dark exposure. Envisage created FITS files, 32 bit floats. The range is 0-65535, as indicated by the RANGE keyword. BSCALE is 1 and BZERO is 0. All these values are correct unless the standard makes absolutely no sense.

When I load the 1ms file into fv it shows values in the thousands. DS9 agrees. When PCL loads the file it shows it as entirely white. Average is around 0.9 or so. It should be around 0.05.

Load the 4m file. Since this one has some hot pixels the range is much greater and therefore the scaling that PCL does on load isn't as obvious.

Now load the -mod file. I made 1 pixel 0 and 1 pixel 65535. Now the file loads correctly. The histogram is where I'd expect it.

Needless to say I do not want to change my data just to work with PCL. Changing a header field is one this, messing with the data is another.

Now. Either PCL is broken or you purposely do it this way. Why doesn't PCL honor the RANGE keyword? That would solve it. If that's not possible could you please add an option to the FITS loaded to keep the dynamic range of the original file? Not sure why you'd ever want to throw away the original dynamic range but since PCL has been doing it this long there must be a philosophical difference of opinion here.

Thanks,

  Sander
Best,

    Sander
---
Edge HD 1100
QHY-8 for imaging, IMG0H mono for guiding, video cameras for occulations
ASI224, QHY5L-IIc
HyperStar3
WO-M110ED+FR-III/TRF-2008
Takahashi EM-400
PIxInsight, DeepSkyStacker, PHD, Nebulosity

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Sorry, I think I did a mistake... you should modify the BSCALE (set to 65355) keyword, not the RANGE one.
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/
Quote
Why doesn't PCL honor the RANGE keyword?


Because it is not part of the FITS standard.

The *only* authority that defines the FITS standard is the IAU FITS Working Group (IAU-FWG).

- To see a list of the standard FITS header keywords and their meaning, please visit this page, maintained by the IAU-FWG.

- To see the official definition of the FITS format, which is the basis for PixInsight/PCL implementation, please download this document in PDF format.

As you can verify in the above documents, the 'RANGE' keyword is just an invention of somebody that does not understand how the FITS format works, and who has not learned the FITS standard definition well.

Our implementation will never honor nonstandard extensions to a format that is perfectly defined and standardized.

Quote
That would solve it.


That would only help propagation of a nonstandard use of the FITS format. We'll never do that. We have resisted other nonstandard FITS implementations by very important telescope-making and software development companies, and this won't be an exception.

What solves your problem is patching the FITS header with a binary editor to set the correct BSCALE keyword value to 65535. Or, if you have to patch many images, an automatized tool, very easy to implement as a JavaScript script or as a simple PCL module, could be the best solution.

Quote
If that's not possible could you please add an option to the FITS loaded to keep the dynamic range of the original file?


You can rest assured that PixInsight keeps the entire dynamic range of the images it loads.

It is very important to know that the dynamic range has nothing to do with the range of values used to store and represent pixel sample values. So it is exactly the same thing if we store sample values in the range [0,1] or in [0,65535], or in [-100000,+100000], as long as we ensure that roundoff and truncation errors are not degrading the data beyond the accuracy inherent to the representation data types (either 32-bit or 64-bit IEEE 754 floating point formats). In fact, the [0,1] range is the best suited in this sense.

Please realize that we can't modify our platform, which works very well as it is, just to honor the  whims and incorrect implementations of others.

PixInsight stores internally all floating point real and complex images in the normalized [0,1] range, and this is not going to change. There are lots of reasons. Yesterday I enumerated some of them, but there are much more. Most of them are purely algorithmic. Our platform would see a substantial degradation in performance, and our software development framework (PCL) would be much less operative without the [0,1] range.

Quote
If PCL doesn't do this it's pointless to use it for pixel math, channel combination and other operations that involve multiple files.


You can do extremely complex pixel math operations and channel combination procedures with PixInsight. Our platform is being used in professional research environments, where this is of course a matter of the utmost importance. A recent example is the Alhambra Survey:

http://www.caha.es/alhambra-the-history-of-the-universe-at-sight.html

Search for the word PixInsight in the above document. Alhambra uses more than 20 bandpass filters to explore a large segment of the spectrum. All of these images must be combined to form a single RGB image, which is an extremely difficult and delicate task. This is being done with PixInsight on a regular basis.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Nocturnal

  • PixInsight Jedi Council Member
  • *******
  • Posts: 2727
    • http://www.carpephoton.com
Hi Juan,

Quote
What solves your problem is patching the FITS header with a binary editor to set the correct BSCALE keyword value to 65535


Nonsense. I tried it and it didn't work. For your convenience I've copied part of the standard that you keep smacking around:

Quote
KEYWORD:   BSCALE
REFERENCE: FITS Standard
STATUS:    reserved
HDU:       image
VALUE:     real
DEFAULT:   1.0
COMMENT:   linear factor in scaling equation
DEFINITION: This keyword shall be used, along with the BZERO keyword,
when the array pixel values are not the true physical values, to
transform the primary data array values to the true physical values
they represent, using the equation: physical_value = BZERO + BSCALE *
array_value.  The value field shall contain a floating point number
representing the coefficient of the linear term in the scaling
equation, the ratio of physical value to array value at zero offset.
The default value for this keyword is 1.0.


So you're saying that with a BSCALE of 65535 all of a sudden the file would load ok? That would mean that a pixel value of say 3000 would become 196605000. Is this what you want? No. If pixel values were between 0 and 1 (like PCL saves them) THEN the BSCALE would have to be 65535. That is what the file was like that you made for me. You modified the BSCALE AND the data. That is how I found out PCL changes the data when it gets saved.

Obviously I don't know what I'm talking about and please don't change PCL to confirm to my wishes but if PCL scales the data that it reads to fit the 0-1 range based on the min and max of the data it reads then two images from the same sensor can not be reliably compared nor can meaningful math be performed. I have clearly demonstrated this fact by providing you unmodified and patched data. The way PCL reads the FITS file changes based on the data in the file. Absurd.

Here is proof in case you need it. The statistics for the modified file (1 pixel set to 0, 1 pixel set to 65535):

            ____K____
Mean....... 0.0998660
Median..... 0.0998856
StdDev..... 0.0018565
AvgDev..... 0.0002835
Variance... 0.0000034
Minimum.... 0.0000000
MinPos..... (0,486)
Maximum.... 1.0000000
MaxPos..... (0,487)
Count...... 247904

Here is the data for the unmodified frame:

            ____K____
Mean....... 0.9854698
Median..... 0.9856949
StdDev..... 0.0036657
AvgDev..... 0.0027601
Variance... 0.0000134
Minimum.... 0.9626562
MinPos..... (7,3)
Maximum.... 1.0000000
MaxPos..... (149,367)
Count...... 247904



TWO PIXELS ARE DIFFERENT! Look at the huge difference in stats. Doing pixel math subtraction of these two images should show only those two pixels (top left) but you know it won't. Conclusion: it is pointless to do pixel math on images that don't have the same scale or understanding of 0 and max. You can not do dark subtraction if the dark frame and the light frame are not in the same scale. You can not do LRGB merging if the frames don't have the same scale. Do I need to continue? I think (hope) you get the point.

Quote

It is very important to know that the dynamic range has nothing to do with the range of values used to store and represent pixel sample values. So it is exactly the same thing if we store sample values in the range [0,1] or in [0,65535], or in [-100000,+100000], as long as we ensure that roundoff and truncation errors are not degrading the data beyond the accuracy inherent to the representation data types (either 32-bit or 64-bit IEEE 754 floating point formats). In fact, the [0,1] range is the best suited in this sense.


If my image contains values between 3000 and 4000 PCL scales these between 0 and 1, right? You now have a dynamic range of 1000. What it SHOULD do is normalize 0 as 0 and 1 as 65535. Now load the pixels. Dynamic range is 65535. You have removed the offset at the top and bottom. Sort of like an automatic histogram stretch. Yet you try to school me on dynamic range. Scaling to 0-1 is fine but you can not seriously claim that you've preserved the dynamic range of the image if you chop the top and bottom off. As soon as you've done this you can no longer correlate two images and do math on them unless you are sure they have the same max and min values in the original file. Unfortunately unless I add the 0 and 65535 values I can not be sure of that without inspecting the file.

Setting BSCALE to 65535 is not the solution. Adding a 0 and 65535 pixel seems to work. DeepSkyStacker recognizes an Envisage FITS and sets the min and max accordingly. Scaling the data from 0-65535 to 0-1 and setting BSCALE to 65535 would work. Recognizing the RANGE keyword would work. Allowing the user to set the range when loading a FITS file would work.


It's clear this is not about how Envisage stores the data. It's philosophical. You think it's fine to discard the top and bottom of the range simply because those values aren't used so it's pointless to proceed. It's making me mad and raising my blood pressure so let's end it here.

All the best and good luck with PCL. It is wonderful software.

   Sander[/quote]
Best,

    Sander
---
Edge HD 1100
QHY-8 for imaging, IMG0H mono for guiding, video cameras for occulations
ASI224, QHY5L-IIc
HyperStar3
WO-M110ED+FR-III/TRF-2008
Takahashi EM-400
PIxInsight, DeepSkyStacker, PHD, Nebulosity

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Hi Sander,

Well, let's calm a bit and keep our pressure within healthy limits :)

I apologize for some things that I said in my previous post. Too much pressure I guess...

After reading your message, I have made a more in-depth investigation and have read relevant parts of the New Proposed Version 3.0 (DRAFT) FITS Standard document. It's here:

http://fits.gsfc.nasa.gov/draft/fits_standard_30.pdf

In this document we can read:

Quote
5.3     IEEE-754 Floating-Point
Transmission of 32- and 64-bit floating-point data within the FITS format shall use
the ANSI/IEEE-754 standard [21]. BITPIX = -32 and BITPIX = -64 signify 32- and
64-bit IEEE floating-point numbers, respectively; the absolute value of BITPIX is used
for computing the sizes of data structures. The full IEEE set of number forms is allowed
for FITS interchange, including all special values.
    The BLANK keyword should not be used when BITPIX = -32 or -64; rather, the
IEEE NaN should be used to represent an undefined value. Use of the BSCALE and
BZERO keywords is not recommended.


So it is clear that the new proposed standard discourages the use of BSCALE and BZERO as we are currently using them. I stand corrected, and consequently, I'll try to make the necessary changes to our implementation ASAP.

Now here comes the real problem. I'll explain what the PCL does for floating point real FITS images.

When an image stores pixels as floating point numbers we face the following problem: there is no prescribed physical range of sample values. This is because we are representing pixels as real numbers, which are defined in the {-infinite,+infinite} interval.

Contrarily, when an image stores integer pixels, we have a finite set of values that each pixel sample can take: [0, 2^n - 1] in the case of unsigned integers. This is [0,65535] for 16-bit unsigned integers.

So, how can be know what the actual range of values is in a floating point image? The problem here is that the pixel values by themselves are not enough to derive the actual range. So we need some extra information. The (proposed and current) standard says:

Quote
The full IEEE set of number forms is allowed
for FITS interchange, including all special values.


However, how can we know the actual range of values, as I have said? The above sentence just allows us to use the full range of IEEE 754 values, including singular values (NAN and the like). However it says nothing about sample values and their actual ranges.

In practice, we need to define a range [a,b] of values such that:

- a represents the minimum possible sample value. This is equivalent to the "no signal" condition, say "black".

- b represents the maximum possible sample value. This is equivalent to the "full signal" condition, say "white".

In other words, [a,b] represents the underlying total dynamic range where the image has been represented (note that this is not the same that the range [min,max] where min is the minimum value present in the image, and max is the maximum present value).

For floating point FITS images, PixInsight/PCL uses the BZERO and BSCALE keywords as follows for floating point FITS images:

[1]
image_value = (array_value - BZERO)/(BSCALE - BZERO)

only when BZERO != 0 and BSCALE != 1 so we end with all pixel values expressed in the [0,1] range. Of course, this is bad practice, but what else can we do?

You are right in that this is actually contrary to what the standard states:

physical_value = BZERO + BSCALE * array_value

which is valid for integer images. However, our implementation makes use of existing standard keywords instead of inventing some others ad-hoc, and it only does that when there is no other alternative, that is, by default PCL writes FITS images in the [1,0] range with BZERO=0 and BSCALE=1, which is completely standards-compliant.

Quote
So you're saying that with a BSCALE of 65535 all of a sudden the file would load ok?


It would load ok with the current PCL implementation (and many others as well, in fact). However as I have said at the beginning of this post, this is going to change.

What we are not going to do is adopting that RANGE keyword, because it does not appear neither in the current standard nor in the proposed one.

This is a complex topic and we need to sit and think on it with calm and ensuring that we made the correct decisions.

I have to say you thanks for helping me in rethinking this. At the end of this we'll achieve a much better and solid implementation.

Now about your problem with envisage's files. One question, could you save the images as 16-bit FITS instead of floating point? Consider that you have no advantage in saving them as floating point, because they are raw unprocessed images. As 16-bit integer FITS there would be no problem at all to load them in PixInsight.

[1] Edited Oct 14 : I have replaced the expression indicated above with the correct one.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Hi Juan

In my opinion, there should be no truncation of out of range (defined by BZERO and BSCALE, for example) values both for writing and reading fits files. I'll give you an example. Let's say we have the laplacian of an image. As you know, it will contain negative values, and very likely, other values over 1. It would be nice to save that image, and then read them, keeping pixel values intact.
Just a I interpret the BZERO and BSCALE values, they are not meant for no signal and signal saturation definition... since we are working with floating point data, it should be just a way to tell the program how to represent (display) data. Of course, internally the pixel values should be changed if any (or both) of those values are not the default ones, so processes will handle data as they should. Later we can restore the data scale setting the propper BSCALE value.
Regards,

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