Changeset 42980
- Timestamp:
- Apr 9, 2026, 8:45:39 AM (4 weeks ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPARead.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPARead.c
r34085 r42980 194 194 195 195 return naxis3; 196 } 197 198 bool applyBLANKifIntType (psImage *output, psImage *input, psMetadata *header) { 199 200 // if the input image is an integer type, then the psFitsReadImage 201 // did not interpret the image being read as a float-equivalent. 202 // In that case, it does not apply the BLANK value because it is 203 // returning an integer image. however, if we convert this image to a 204 // float type, we need to fix BLANK values. we can only do that if 205 // there is a valid header with the keyword BLANK. 206 207 if (!output) return false; // no valid input image, do not attempt 208 psElemType outDatatype = output->type.type; 209 210 bool floatOutput = false; 211 floatOutput = floatOutput || (outDatatype == PS_TYPE_F32); 212 floatOutput = floatOutput || (outDatatype == PS_TYPE_F64); 213 if (!floatOutput) return false; 214 215 if (!input) return false; // no valid input image, do not attempt 216 psElemType inDatatype = input->type.type; 217 218 if (inDatatype == PS_TYPE_F32) return false; // not an INT type, skip 219 if (inDatatype == PS_TYPE_F64) return false; // not an INT type, skip 220 221 if (!header) return false; // no header, no info on 'blank', do not attempt 222 223 bool mdstat; 224 int blankValue = psMetadataLookupS32 (&mdstat, header, "BLANK"); 225 if (!mdstat) return false; // no BLANK value, do not attempt 226 227 int numRows = input->numRows; 228 int numCols = input->numCols; 229 230 # define APPLY_BLANK_TO_OUTPUT(IN,INTYPE,OUT,OUTTYPE) { \ 231 ps##INTYPE *in; \ 232 ps##OUTTYPE *out; \ 233 for (int row = 0; row < numRows; row++) { \ 234 in = IN->data.INTYPE[row]; \ 235 out = OUT->data.OUTTYPE[row]; \ 236 for (int col = 0; col < numCols; col++) { \ 237 if (*in == blankValue) { *out = NAN; } \ 238 out++; in++; \ 239 } \ 240 } \ 241 } 242 243 switch (outDatatype) { 244 case PS_TYPE_F32: 245 switch (inDatatype) { 246 case PS_TYPE_U8: APPLY_BLANK_TO_OUTPUT(input, U8, output, F32); break; 247 case PS_TYPE_U16: APPLY_BLANK_TO_OUTPUT(input, U16, output, F32); break; 248 case PS_TYPE_U32: APPLY_BLANK_TO_OUTPUT(input, U32, output, F32); break; 249 case PS_TYPE_U64: APPLY_BLANK_TO_OUTPUT(input, U64, output, F32); break; 250 case PS_TYPE_S8: APPLY_BLANK_TO_OUTPUT(input, S8, output, F32); break; 251 case PS_TYPE_S16: APPLY_BLANK_TO_OUTPUT(input, S16, output, F32); break; 252 case PS_TYPE_S32: APPLY_BLANK_TO_OUTPUT(input, S32, output, F32); break; 253 case PS_TYPE_S64: APPLY_BLANK_TO_OUTPUT(input, S64, output, F32); break; 254 default: 255 break; 256 } 257 case PS_TYPE_F64: 258 switch (inDatatype) { 259 case PS_TYPE_U8: 260 APPLY_BLANK_TO_OUTPUT(input, U8, output, F64); 261 break; 262 case PS_TYPE_U16: 263 APPLY_BLANK_TO_OUTPUT(input, U16, output, F64); 264 break; 265 case PS_TYPE_U32: 266 APPLY_BLANK_TO_OUTPUT(input, U32, output, F64); 267 break; 268 case PS_TYPE_U64: 269 APPLY_BLANK_TO_OUTPUT(input, U64, output, F64); 270 break; 271 default: 272 break; 273 } 274 default: 275 break; 276 } 277 return true; 196 278 } 197 279 … … 754 836 if (source->type.type != imageType) { 755 837 psImage *temp = psImageCopy(NULL, source, imageType); // Temporary image 838 839 // if the input image is an integer type, then the BLANK value was not applied by psImageRead 840 // if we are converting to a floating point type, then we need to set BLANK values to NAN (if it exists) 841 applyBLANKifIntType (temp, source, hdu->header); 842 756 843 psFree(imageArray->data[i]); 757 844 imageArray->data[i] = temp;
Note:
See TracChangeset
for help on using the changeset viewer.
