Hello
I am trying to use opencv inpainting tools via opencv-python package (version ‘4.5.5’).
In my starting tests I have suceed using cv2.inpaint ( both cv2.INPAINT_NS and cv2.INPAINT_TELEA algorithms ). However, using cv2.xphoto.inpaint, I am only suceed using cv2.xphoto.INPAINT_SHIFTMAP algorithm. I am not able to get results when using INPAINT_FSR_FAST and cv2.xphoto.INPAINT_FSR_BEST.
The images to inpaint are multiband (ENVI format) and I want to inpaint band by band and then stack the inpainted bands in a result inpainted file.The succesful line code for SHIFTMAP algorithm:
cv2.xphoto.inpaint(band2xphoto, mask_inv, res_SHIFTMAP, cv2.xphoto.INPAINT_SHIFTMAP)
The failing lines codes for FSRBEST and FSRFAST:
cv2.xphoto.inpaint(band2xphoto,mask_inv, res_FSRBEST, cv2.xphoto.INPAINT_FSR_BEST)
cv2.xphoto.inpaint(band2xphoto,mask_inv, res_FSRFAST, cv2.xphoto.INPAINT_FSR_FAST)
The type of all data arrays are numpy.ndarray and their data types are:
mask_inv.dtype: dtype('uint8')
band2xphoto.dtype: dtype('float32')
res_FSRBEST.dtype: dtype('float32')
res_FSRFAST.dtype: dtype('float32')
The shapes of the data are the same (569, 888)
The mask_inv values are: 1 for valid data y 0 for pixel to be inpainted
According the opencv documentation for cv2.xphoto,inpaint (INPAINT_FSR_BEST and INPAINT_FSR_FAST algorithms), the data range for band2xphoto float32 array lies between 0 to 1.
The output python error is:
cv2.xphoto.inpaint(band2xphoto,mask_inv, res_FSRBEST, cv2.xphoto.INPAINT_FSR_BEST)
Traceback (most recent call last):
File "/var/folders/86/70ygk3f915z5fwd7nrqc5g9r0000gn/T/ipykernel_62454/3241883758.py", line 1, in <cell line: 1>
cv2.xphoto.inpaint(band2xphoto,mask_inv, res_FSRBEST, cv2.xphoto.INPAINT_FSR_BEST)
error: OpenCV(4.5.5) /Users/runner/miniforge3/conda-bld/libopencv_1648505771520/work/modules/core/src/matrix_wrap.cpp:1166: error: (-215:Assertion failed) !fixedType() || ((Mat*)obj)->type() == mtype in function 'create'
Looking for help in the web, I guess that the problem could be related to opencv types detailed in the opencv documentation:
"1-channel grayscale or 3-channel BGR image are accepted.
Conventional accepted ranges:
0-255 for CV_8U
0-65535 for CV_16U
0-1 for CV_32F/CV_64F."
However, I am not sure that that was the problem. Nevertheless, I do not succed in managing this issue
Regards
Josep