MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / getType

Method getType

ij/src/main/java/ij/astro/util/ImageType.java:452–474  ·  view source on GitHub ↗
(Object rawData, double bScale, double bZero)

Source from the content-addressed store, hash-verified

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) {

Callers 4

saveImageMethod · 0.95
mergeHeadersMethod · 0.95

Calls 5

valuesMethod · 0.80
isInstanceMethod · 0.80
isFloatingPointMethod · 0.80
getBZeroMethod · 0.45
getBitDepthMethod · 0.45

Tested by

no test coverage detected