twVolc / PyCamPermanent

Permanent PiCam (SO2) installation project software
GNU General Public License v3.0
2 stars 2 forks source link

Image registration a bit buggy (appears to hold onto old registrations) #134

Open twVolc opened 4 months ago

twVolc commented 4 months ago

I've encountered bugs with image registration a number of times when moving between data and generally doing processing. Sometimes it's been hard to keep track of what exactly I've done to recreate the error, so I've just let it slide, but think I need to document this now as I've found at least one way to easily reproduce a bug:

  1. Start software, the GUI loads with default villaricca data, and defaut openCV registration
  2. Load new image sequence (I load some Reventador data) - as expected, the registration is poor because it still has the Villaricca loaded.
  3. There's a few bugs here

Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\thom_\anaconda3\envs\pycam\lib\tkinter\__init__.py", line 1892, in __call__ return self.func(*args) File "C:\Users\thom_\Documents\Work\pycam_dev\PyCamPermanent\pycam\gui\figures_cam.py", line 466, in <lambda> command=lambda: self.img_reg_select(self.reg_meth)) File "C:\Users\thom_\Documents\Work\pycam_dev\PyCamPermanent\pycam\gui\figures_cam.py", line 540, in img_reg_select self.pyplis_worker.register_image(**kwargs) File "C:\Users\thom_\Documents\Work\pycam_dev\PyCamPermanent\pycam\so2_camera_processor.py", line 1147, in register_image self.img_B.img_warped = self.img_reg.register_image(self.img_A.img, self.img_B.img, **kwargs) File "C:\Users\thom_\Documents\Work\pycam_dev\PyCamPermanent\pycam\so2_camera_processor.py", line 4066, in register_image warped_B = self.cv_warp_img(img_B) File "C:\Users\thom_\Documents\Work\pycam_dev\PyCamPermanent\pycam\so2_camera_processor.py", line 4022, in cv_warp_img img_warped = cv2.warpAffine(img, self.warp_matrix_cv, (sz[1], sz[0]), cv2.error: OpenCV(4.9.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\imgwarp.cpp:2757: error: (-215:Assertion failed) (M0.type() == CV_32F || M0.type() == CV_64F) && M0.rows == 2 && M0.cols == 3 in function 'cv::warpAffine'

I would suggest keeping this issue to document any other bugs we may find relating to this.

For context on how the warping is implemented: rather than creating a new PyplisWorker attribute called img_B_warped I decided to just give PyplisWorker.img_B a new attribute called img_warped. Perhaps things aren't correctly updated at times or there is an artifact of old warping that hasn't bee updated, for instance in other attributes later in the processing pipeline that stem from img_B_warped (e.g PyplisWorker.vign_corr_B_warped)

twVolc commented 1 month ago

Related to this, the SO2 image in the analysis pane doesn't update after updating image registration. This is quite a significant bug as it means you can't see changes related to image registration - could lead the user to think a registration is better or worse than it really is. Dragging the ROI on the SO2 image then updates the figure to the new correct registration, but this shouldn't be required to update the plot. I'm not sure it has always been like this so I'm guessing some of our other updates have led to this bug.

ubdbra001 commented 3 days ago

Related to this, the SO2 image in the analysis pane doesn't update after updating image registration. This is quite a significant bug as it means you can't see changes related to image registration - could lead the user to think a registration is better or worse than it really is. Dragging the ROI on the SO2 image then updates the figure to the new correct registration, but this shouldn't be required to update the plot. I'm not sure it has always been like this so I'm guessing some of our other updates have led to this bug.

How would I go about recreating this? Something like:

twVolc commented 3 days ago

How would I go about recreating this? Something like:

  • Load a new image directory manually (i.e. not through a config file)
  • Update the registration
  • Switch to the analysis window

Yep I'm pretty sure this is how I did it. I think you'll notice if you then change the ROI the analysis window will update and things will look quite different. I can't remember for certain though.