3
$\begingroup$

I have a hard problem that need your help. I have a binary image that maintains some unwanted region (small white dot) and hole regions (in figure 1).My idea is that the first I will remove unwanted region by calculating area these region and then filter with small area value.At the second step, I fill in hole region to make clear image.What do you think best method to fill in hole region. D.Because my idea need threshold value to remove unwanted region. I want to find automatic method to do it. Do you have any idea to resolve it? Thank you so much. This is my reference code for remove unwanted region. But it need threshold term. You can download image test at here

function exImage=rmUnwantedRegion(Img,threshold)
    lb = bwlabel(Img);
    st = regionprops(lb, 'Area', 'PixelIdxList' );
    toRemove = [st.Area] <threshold; % fix your threshold here
    exImage = Img;
    exImage( vertcat(st(toRemove).PixelIdxList ) ) = 0; % remove
 end

enter image description here

$\endgroup$
5
$\begingroup$

This code work fine for me. You try

RGB = imread('Image/input.png');

GRAY = rgb2gray(RGB);
threshold = graythresh(GRAY);
originalImage = im2bw(GRAY, threshold);

originalImage = bwareaopen(originalImage,250);
se = strel('disk', 10); %# structuring element
closeBW = imclose(originalImage,se);

imshow(closeBW);

Rsultant image

$\endgroup$
  • $\begingroup$ You can increase or decrease the value in se = strel('disk', 10); to get more appropriate result. $\endgroup$ – Asif Sharif Apr 29 '14 at 14:54
  • $\begingroup$ Thank you sir, my error is that my upload image (in above link) is RGB image. But my original image (create by my code is binary image. So I cannot apply "RGB = imread('Image/input.png'); GRAY = rgb2gray(RGB); threshold = graythresh(GRAY);". So the my result is bad. Please check agian with original image and re-implement help me?dropbox.com/s/mvodekty93scckm/input.mat $\endgroup$ – John Apr 29 '14 at 16:17
  • $\begingroup$ Then you have to remove these three line and just use below code only.. originalImage = imread('Image/input.png'); originalImage = bwareaopen(originalImage,250); se = strel('disk', 10); %# structuring element closeBW = imclose(originalImage,se); imshow(closeBW); $\endgroup$ – Asif Sharif Jul 2 '14 at 5:31
  • $\begingroup$ Do you know a Python solution? $\endgroup$ – Sigur Dec 17 '18 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.