From 84a71896f81a1d5e33b25f5a682bafe68659544e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Poizl?= Date: Sun, 10 Apr 2022 17:37:10 +0200 Subject: [PATCH] Fix laoding 16 bit signed files --- loadrunable.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/loadrunable.cpp b/loadrunable.cpp index 94c12db..a20b079 100644 --- a/loadrunable.cpp +++ b/loadrunable.cpp @@ -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); }