提问人:Tellun 提问时间:8/16/2023 最后编辑:Tellun 更新时间:8/16/2023 访问量:100
我可以将 OpenCV SIFT 用于 16 位图像吗?
Can I use OpenCV SIFT for 16bit images?
问:
我正在尝试注册两个 16 位映像。一个是.dcm CT系列,另一个是TIFF图像。两者都是 uint16 类型,在运行 SIFT 时出现此错误:
cv2.error:OpenCV(4.8.0) D:\a\opencv-python\opencv-python\opencv\modules\features2d\src\sift.dispatch.cpp:512:错误:(-5:错误参数)图像为空或在函数“cv::SIFT_Impl::d etectAndCompute”中具有不正确的深度 (!=CV_8U)
似乎 OpenCV 仅适用于 8 位(至少这是我理解消息的方式),所以我的问题是......有人有任何解决方法吗?
我可以将图像传输到 uint8,但它弄乱了 CT 系列,总体上降低了测量精度,这是次优的。
我没有尝试过任何东西,因为我还没有弄清楚任何事情。
代码如下:
def __init__(self, film_path, CT_path, min_match_count=10):
self.detector = cv.SIFT_create()
self.img_g = cv.cvtColor(tiff.imread(film_path), cv.COLOR_BGR2GRAY)
if '.dcm' in CT_path:
self.CT = dcm.dcmread(CT_path).pixel_array
else:
self.CT_dir = os.listdir(CT_path)
self.min_match_count = min_match_count
def load_ct(self):
for slc in self.CT_dir:
CT_slice = dcm.dcmread(CT_path).pixel_array
CT.append(CT_slice)
return np.array(CT)
def detect(self, CT2detect):
kp_self, des_self = self.detector.detectAndCompute(self.img_g, None)
FLANN_INDEX_KDTREE = 1
index_params = dict(algorithm=FLANN_INDEX_KDTREE, trees=5)
search_params = dict(checks=50)
matcher = cv.FlannBasedMatcher(index_params, search_params)
img = CT2detect[:, :, 383]
im = img.copy()
kp, des = self.detector.detectAndCompute(img, None)
...
答: 暂无答案
评论