Okay, I discovered the answer. I sum it up here for the record. For imbinarize(I,T), T must be a double between 0 and 1 (though I can be uint8 or double, it doesn't matter).
imbinarize sets every pixel of an image to 0 regardless of the level set
    5 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Bálint Décsi
      
 el 13 de Sept. de 2020
  
    
    
    
    
    Respondida: Bálint Décsi
      
 el 13 de Sept. de 2020
            Description
In the code part below I have problems with the TH matrix, output of the function. IMG and level are an rgb image and a value between 0 and 255, respectively. The function imbinarize sets each pixel ot TH to 0 and I don't know why. Is it something very trivial I fail to take into consideration?
function [TH] = threshold(IMG, level)
szrgb = size(IMG,3);
if szrgb ~= 1
    warning('Input image is not grayscale, an attempt to convert it will be made')
    IMG = rgb2gray(IMG);
end
TH = imbinarize(IMG, level);
end
Steps that did not solve my problem
I checked every step in debug mode. Went with different values for level. Converted level into int8 before calling imbinarize. Also, imbinarize(IMG), when the function uses Otsu's method for the right threshold, works fine.
0 comentarios
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
				Más información sobre Image Processing Toolbox en Help Center y File Exchange.
			
	Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
