Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inpainting support for float32 data #4542

Closed
opencv-pushbot opened this issue Jul 27, 2015 · 1 comment · Fixed by #8776
Closed

Inpainting support for float32 data #4542

opencv-pushbot opened this issue Jul 27, 2015 · 1 comment · Fixed by #8776

Comments

@opencv-pushbot
Copy link
Contributor

Transferred from http://code.opencv.org/issues/2944

|| David Shean on 2013-04-08 06:12
|| Priority: Normal
|| Affected: None
|| Category: photo
|| Tracker: Feature
|| Difficulty: None
|| PR: 
|| Platform: None / None

Inpainting support for float32 data

The geospatial data community often works with single-band int16 or float32 raster data (e.g. digital surface models [DSM], spectrometer data) that contain "holes" of nodata pixels (e.g., bad pixels, data drops during transfer from spacecraft, occlusions in photogrammetric DSM products).  For some analyses, it is desirable to preserve these nodata values, but often, a continuous data product is required (e.g. removal of buildings to produce a digital terrain model, using a DSM for image orthorectification, etc.).  

Contemporary inpainting methods offer highly effective hole-filling capabilities.  If the OpenCV inpainting functionality offered support for float32 inputs, it would definitely be used by new communities outside of traditional CV/photography.  Members of the astronomy community also face similar issues (http://astrolitterbox.blogspot.com/2012/03/healing-holes-in-arrays-in-python.html).

A quick glance at https://github.com/Itseez/opencv/blob/master/modules/photo/src/inpaint.cpp suggests that the output of both single-band inpainting methods is recast to 8-bit:

icvTeleaInpaintFMM
sat = (float)((Ia/s+(Jx+Jy)/(sqrt(Jx*Jx+Jy*Jy)+1.0e-20f)+0.5f));
CV_MAT_ELEM(*out,uchar,i-1,j-1) = cv::saturate_cast<uchar>(sat);

icvNSInpaintFMM
Ia += (float)w * (float)(CV_MAT_ELEM(*out,uchar,km,lm));
CV_MAT_ELEM(*out,uchar,i-1,j-1) = cv::saturate_cast<uchar>((double)Ia/s); #s is also float

Seems like it would be relatively straightforward to support CV_32F?  I'm still learning, and I'm not quite ready to tackle on my own at this point.  Thanks.

History

François-Xavier Thomas on 2015-05-04 14:50
I second this. I got a somewhat working version by pre-scaling my raster array to 8-bit, then scaling it back after calling @cv2.inpaint@, however it would be great if that use case were covered by OpenCV directly.
@pstack12
Copy link

I also have a use for the inpainting function to support floats or doubles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants