Reputation: 1
I am trying to register two 16bit images. One is a .dcm CT series and the other is TIFF image. Both are uint16 type and while running SIFT I get this error:
cv2.error: OpenCV(4.8.0) D:\a\opencv-python\opencv-python\opencv\modules\features2d\src\sift.dispatch.cpp:512: error: (-5:Bad argument) image is empty or has incorrect depth (!=CV_8U) in function 'cv::SIFT_Impl::detectAndCompute'
It appears OpenCV only works with 8bit (atleast that's the way I understand the message), so my question is...does anybody have any work-arounds?
I could transfer the images to uint8, but it messes up the CT series and overall decreases accuracy of the measurement which is suboptimal.
I haven't tried anything as I haven't figured out anything.
Here is the code:
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)
...
Upvotes: 0
Views: 250