I want to align a list of images (already as np arrays) using pystackreg
to stack them. I tried this:
imagefiles=glob.glob(r"C:\Users\HP\My Python stuff\openCV\Polarization\*degrees.jpg")
imagefiles.sort()
images=[]
for filename in imagefiles:
img=cv2.imread(filename)
img=cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
img=np.int16(img)
images.append(img)
sr=StackReg(StackReg.AFFINE)
alimages=sr.register_transform_stack(images, reference='first')
which thows this error message:
~\anaconda3\lib\site-packages\pystackreg\pystackreg.py in register_stack(self, img, reference, n_frames, axis, moving_average, verbose, progress_callback, suppress_axis_warning)
320 )
321
--> 322 if len(img.shape) != 3:
323 raise Exception("Stack must have three dimensions")
324
AttributeError: 'list' object has no attribute 'shape'
I think the entire stack of images needs to be a 3d array. how can i do that? and would it work in RGB images and grayscales alike?
the documentation only covers loading a stack from a multi frame tiff like this:
img0 = io.imread('some_multiframe_image.tif') # 3 dimensions : frames x width x height
sr = StackReg(StackReg.RIGID_BODY)
out_first = sr.register_transform_stack(img0, reference='first')