Fix laoding 16 bit signed files

This commit is contained in:
2022-04-10 17:37:10 +02:00
parent 0ba02d4070
commit 84a71896f8
+7
View File
@@ -184,6 +184,7 @@ bool loadFITS(QString path, ImageInfoData &info, RawImage **image)
int naxis; int naxis;
long naxes[3] = {0}; long naxes[3] = {0};
fits_get_img_param(file, 3, &imgtype, &naxis, naxes, &status); fits_get_img_param(file, 3, &imgtype, &naxis, naxes, &status);
fits_get_img_equivtype(file, &imgtype, &status);
if(naxis >= 2 && naxis <= 3 && status == 0) if(naxis >= 2 && naxis <= 3 && status == 0)
{ {
@@ -198,6 +199,10 @@ bool loadFITS(QString path, ImageInfoData &info, RawImage **image)
fitstype = TBYTE; fitstype = TBYTE;
break; break;
case SHORT_IMG: case SHORT_IMG:
cvtype = CV_16S;
fitstype = TSHORT;
break;
case USHORT_IMG:
cvtype = CV_16U; cvtype = CV_16U;
fitstype = TUSHORT; fitstype = TUSHORT;
break; break;
@@ -219,6 +224,8 @@ bool loadFITS(QString path, ImageInfoData &info, RawImage **image)
cv::Mat tmp(h, w, cvtype); cv::Mat tmp(h, w, cvtype);
fpixel[2] = i; fpixel[2] = i;
fits_read_pix(file, fitstype, fpixel, size, NULL, tmp.ptr(), NULL, &status); fits_read_pix(file, fitstype, fpixel, size, NULL, tmp.ptr(), NULL, &status);
if(cvtype == CV_16S)
tmp.convertTo(tmp, CV_16U, 1, 32767);
cvimg.push_back(tmp); cvimg.push_back(tmp);
} }