(Object rawData, double bScale, double bZero)
| 450 | } |
| 451 | |
| 452 | public static ImageType getType(Object rawData, double bScale, double bZero) { |
| 453 | for (ImageType type : values()) { |
| 454 | if (type.rawDataType.isInstance(rawData)) { |
| 455 | // FITS Standard 4.0, Section 4.4.2.5. Keywords that describe arrays |
| 456 | // Some files may represent floating point data as integer data, relying on the scaling to |
| 457 | // restore the correct values. |
| 458 | // "This linear scaling technique is still commonly used to reduce the size of the data array |
| 459 | // by a factor of two by representing 32-bit floating-point physical values as 16-bit scaled integers." |
| 460 | // eg. These values, when applied to integer types are used for storing floating point values UNLESS |
| 461 | // BSCALE = 1 and BZERO equals the listed BZERO value from Table 11 of the FITS Standard |
| 462 | // (encoded here in ImageType#getBZero). |
| 463 | if (!type.isFloatingPoint() && bScale != 1 && bZero != type.getBZero()) { |
| 464 | return ImageType.FLOAT; |
| 465 | } |
| 466 | |
| 467 | //todo we probably aren't handling the unsigned non-byte types very well, they need to be promoted |
| 468 | // to the next size up or converted to floats if too large |
| 469 | |
| 470 | return type; |
| 471 | } |
| 472 | } |
| 473 | throw new IllegalStateException("Tried to open image data that was not a numeric: " + rawData.getClass()); |
| 474 | } |
| 475 | |
| 476 | public static ImageType getType(ImageProcessor ip) { |
| 477 | if (ip instanceof IntProcessor) { |
no test coverage detected