imerode/imdilate use convolution?
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Paul Safier
 el 15 de En. de 2025
  
    
    
    
    
    Comentada: Paul Safier
 el 15 de En. de 2025
            Do imerode and imdilate use a convolution (e.g. conv2) under the hood? The source code is not available with their respective .m files.
If they do not, what is the algorithm and could those operations also be accomplished with a convolution? If they do, what is the kernel?
Thanks!
0 comentarios
Respuesta aceptada
  Matt J
      
      
 el 15 de En. de 2025
        
      Editada: Matt J
      
      
 el 15 de En. de 2025
  
      No, imdilate is a sliding window max() operation, which is nonlinear, and therefore not, in general, a convolution. Similarly imerode is a sliding min() operation.
That said, for the special case of a binary image BW and a binary structuring element, you could use a convolution as the workhorse of the computation. For example, out1 and out2 give the same result in the following,
BW=randi([0,1],100,100);
k=randi([0,1],3,3);
out1 = imdilate(BW,k);
out2 = convn(BW,k,'same')>0;
isequal(out1,out2)
Whether the underlying code gives special treatment to this special case and exploits convolution in this way is not clear since, as you said, the code is not divulged to us.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

