Steve on Image Processing with MATLAB

Image processing concepts, algorithms, and MATLAB

Note

Steve on Image Processing with MATLAB has been archived and will not be updated.

Moving the origin of a structuring element

A customer contacted Tech Support recently to ask the following question about structuring elements and dilation:

If I created a structuring element from the matrix [1 1; 1 1], then the origin of the structuring element is the (1,1) or upper-left element. How do I create a structuring element so that the origin is at (1,2) or (2,1)?

There are two equivalent ways to accomplish this.

In the first way, you add a row or column (or both) to the matrix that you pass to strel or imdilate so that the center of the new matrix is the desired structuring element origin. For example:

se = strel([0 1 1; 0 1 1; 0 0 0])
 
se =
 
Flat STREL object containing 4 neighbors.

Neighborhood:
     0     1     1
     0     1     1
     0     0     0

 

In the second way, you pass the original 2-by-2 matrix to strel and then call the function translate to "move" the origin to the desired location.

se = strel([1 1; 1 1])
 
se =
 
Flat STREL object containing 4 neighbors.

Neighborhood:
     1     1
     1     1

 
se2 = translate(se,[-1 0])
 
se2 =
 
Flat STREL object containing 4 neighbors.

Neighborhood:
     0     1     1
     0     1     1
     0     0     0

 




Published with MATLAB® R2015a

|
  • print

댓글

댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.