필터 지우기
필터 지우기

How can i somehow autofill black-spots in an RGB image.

조회 수: 1 (최근 30일)
JAI PRAKASH
JAI PRAKASH 2018년 6월 4일
답변: Image Analyst 2018년 6월 5일

채택된 답변

Aditya Adhikary
Aditya Adhikary 2018년 6월 5일
These may help: imfill and regionfill.
  댓글 수: 1
JAI PRAKASH
JAI PRAKASH 2018년 6월 5일
편집: JAI PRAKASH 2018년 6월 5일
Hey Thanks, But it does not work for complex problems
I used following code:
newimage=imread('City_AskAutofill.jpg');
R = newimage(:,:,1); % splitting RGB because regionfill need grayscale.
G = newimage(:,:,2);
B = newimage(:,:,3);
mask = uint8(R) < 2;
mask = imfill(mask,'holes');
mask = imerode(mask,strel('disk',10));
mask = imdilate(mask,strel('disk',20));
R_autofill = regionfill(R,mask);
mask = uint8(G) < 2;
mask = imfill(mask,'holes');
mask = imerode(mask,strel('disk',10));
mask = imdilate(mask,strel('disk',20));
G_autofill = regionfill(G,mask);
mask = uint8(B) < 2;
mask = imfill(mask,'holes');
mask = imerode(mask,strel('disk',10));
mask = imdilate(mask,strel('disk',20));
B_autofill = regionfill(B,mask);
newimage_autofill(:,:,1)=R_autofill;
newimage_autofill(:,:,2)=G_autofill;
newimage_autofill(:,:,3)=B_autofill;
imtool(newimage_autofill) % this is the image which you are seeing above.
But this approach is not effective on other problem, like I have mentioned further below.
How can I improve this approach. Thanks

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2018년 6월 5일
MATLAB does not have a sophisticated region filling algorithm like the bandage tool in Photoshop. If you want/need something like that, use Photoshop or figure out what algorithm they used and program it up yourself.

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by