inpainting_nans by John D'Errico ERROR MESSAGE

2 次查看(过去 30 天)
I used the inpainting_nans that is available here http://mathworks.com/matlabcentral/fileexchange/4551
I used an image file with a black background picture and a white spot on the middle of it. A = imread('F:\image.bmp');
and i used the inpainting_nans code to see what will be its effect B = inpaint_nans3(A);
But I encountered this error:
?? Error using ==> mtimes Sparse integer array arithmetic operations are not supported.
Error in ==> inpaint_nans3 at 159 rhs=-fda(:,known_list)*A(known_list);
What does this mean?

采纳的回答

Titus Edelhofer
Titus Edelhofer 2011-7-20
Hi, you will probably have to convert the image from integer values to doubles. Try
Ad = double(A);
and run inpaint_nans with Ad ...
Titus
  3 个评论
DGM
DGM 2022-11-6
编辑:DGM 2022-11-6
I should add that if your image is integer-class (e.g. uint8), then it has no NaNs. Casting to 'double' will eliminate the error, but unless you do something to add NaN pixels to the image, there will be nothing for inpaint_nans to fill.
A = imread('cameraman.tif'); % uint8
A = im2double(A); % double, correctly-scaled for its class
% there's nothing to do here
op1 = inpaint_nans(A);
imshow(op1) % the image is unchanged
The above example accomplishes nothing, since there's nothing to inpaint. You'll have to create a mask from something and use that to apply NaNs to the image regions that need to be estimated.
% a logical mask
mk = imread('cmantifmk.png')>128;
% use NaNs to embed the mask in the image
A(mk) = NaN;
% there's actually something to do now
op2 = inpaint_nans(A);
imshow(op2)
... not that that's a good mask to demonstrate inpainting with, but it at least shows that inpainting is happening.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Import, Export, and Conversion 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by