
why imfill resul is a white figure?
    4 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    elena rondina
 il 27 Gen 2016
  
    
    
    
    
    Commentato: elena rondina
 il 27 Gen 2016
            hi i have to close the holes in a image but my resulting is a white figure. Why? where is the problem? my code is:
img=imread('hole.png')
subplot(1,3,1)
imshow(img)
title('image')
%binarization
bw_immage=im2bw(img);
subplot(1,3,2);
imshow(bw_immage);
title('binary image');
%close the holes
i=imfill(bw_immage,'holes');
subplot(1,3,3);
imshow(i);
title('image unless holes');
end
hole.png is:

hole.png is the same immage that use matlab documentation:http://it.mathworks.com/help/images/ref/imfill.html
0 Commenti
Risposta accettata
  Image Analyst
      
      
 il 27 Gen 2016
        
      Modificato: Image Analyst
      
      
 il 27 Gen 2016
  
      Your image had a white frame/border around it. Use imclearborder() to get rid of that. See corrected code:
clc;    % Clear the command window.
close all;  % Close all figures (except those of imtool.)
workspace;  % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
rgbImage = imread('hole.png');
subplot(2,2,1)
imshow(rgbImage)
title('Original Image', 'FontSize', fontSize);
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off') 
%binarization
binaryImage = im2bw(rgbImage);
% Display this image.
subplot(2,2,2);
imshow(binaryImage);
title('Original Binary Image', 'FontSize', fontSize);
% Important: Get rid of surrounding white border (frame):
binaryImage = imclearborder(binaryImage);
% Display this image.
subplot(2,2,3);
imshow(binaryImage);
title('Frame now removed', 'FontSize', fontSize);
%  Close the holes
filledImage = imfill(binaryImage, 'holes');
subplot(2,2,4);
imshow(filledImage);
title('Image without frame or holes', 'FontSize', fontSize);

Più risposte (0)
Vedere anche
Categorie
				Scopri di più su White in Help Center e File Exchange
			
	Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!