Fix laoding 16 bit signed files
This commit is contained in:
@@ -184,6 +184,7 @@ bool loadFITS(QString path, ImageInfoData &info, RawImage **image)
|
||||
int naxis;
|
||||
long naxes[3] = {0};
|
||||
fits_get_img_param(file, 3, &imgtype, &naxis, naxes, &status);
|
||||
fits_get_img_equivtype(file, &imgtype, &status);
|
||||
|
||||
if(naxis >= 2 && naxis <= 3 && status == 0)
|
||||
{
|
||||
@@ -198,6 +199,10 @@ bool loadFITS(QString path, ImageInfoData &info, RawImage **image)
|
||||
fitstype = TBYTE;
|
||||
break;
|
||||
case SHORT_IMG:
|
||||
cvtype = CV_16S;
|
||||
fitstype = TSHORT;
|
||||
break;
|
||||
case USHORT_IMG:
|
||||
cvtype = CV_16U;
|
||||
fitstype = TUSHORT;
|
||||
break;
|
||||
@@ -219,6 +224,8 @@ bool loadFITS(QString path, ImageInfoData &info, RawImage **image)
|
||||
cv::Mat tmp(h, w, cvtype);
|
||||
fpixel[2] = i;
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user