You are on page 1of 10

The Hit or Miss Transform is the

morphological operator used for finding


local patterns of pixels i.e. the size of the
structuring element.

Method:

Method is quite simple .A small odd sized


mask(structuring element ),typically 3x3 is
scanned over a binary image. If the binary-
valued pattern of the structuring element
matches the state of the pixels under the
structuring element(HIT),the output pixel
in spatial correspondence to the center
pixel of the structuring element is set to Note: Here, 1 represents foreground,0
some desired binary state (usually 1).If the represents background and x represents
binary pattern of the structuring element ‘don’t care ‘.
does not match the state of the pixels under
the structuring element(MISS), the output Solution:
pixel in the spatial correspondence to the
center pixel of the structuring element is Original Image:
set to the opposite binary state(usually 0).
0 0 0 0 0 0 0 0 0 0
Let B=(B1,B2) 0 1 1 1 1 1 1 1 0 0
0 1 1 1 1 1 1 1 0 0
be the structuring element.Here B1 is a set 0 1 1 1 1 1 1 1 0 0
formed from elements of B Associated 0 1 1 1 1 1 1 0 0 0
with the objects and B2 is a set of elements 0 1 1 1 1 1 0 0 0 0
of B associated with the corresponding 0 1 1 1 1 0 0 0 0 0
background.B=(B1,B2) 0 1 1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
is called a composite structuring 0 0 0 0 0 0 0 0 0 0
element.The HIT and MISS transformation
of a set A with structuring element B is Hit or Miss using B1:I1
given by the equation
0 0 0 0 0 0 0 0 0 0
A⊗B=a|B1ЄAandB2ЄAc 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
Where A is the image set ,Ac 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
is the complement of the image set and B 0 0 0 0 0 0 0 0 0 0
is the structuring elements. 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
Example: Consider a 10x10 image, apply 0 0 0 0 0 0 0 0 0 0
Hit or Miss transform. 0 0 0 0 0 0 0 0 0 0

Using the following structuring elements:


Hit or Miss using B2:I2 ORing all the resultant images
I1,I2,I3,I4,we get,IResult::
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

Note: If the foreground and background


pixels in the structuring element exactly
match the foreground and background
pixels in the image, then the pixels
underneath the origin of the structuring
element is set to foreground colour. If it
doesn’t match, that pixel is set to
background colour.
Hit or Miss using B3:I3

0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

Hit or Miss using B4:I4

0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
then thin the result with B2 ans so on until
A is thinned with Bn similarly,D is
Thinning: thickened by apply B1,B2……Bn
In thinning the boundary of the object is .
subtracted from the object.

For a image A and a Composite structuring


element B=(B1,B2)

,Thinning can be defined as,

AØB=A∩(A⊗B)C

Thickening:

In Thickening a part of boundary of the


background is added to the object.

For a image A and a Composite structuring


element B = (B1,B2),Thickening can be
defined as,

AʘB=AU(A⊗B)

Thinning and Thickening are dual


operations.i.e.,

(AʘB)C=ACØB;

Thinning and Thickening transformations


are very often used sequentially,

Let B=B1,B2,……Bn

denote a sequence of composite structuring


elements.Here Bn is the rotated version of
Bn-1.Sequential Thinning can then be
expressed as,

AØB=(((AØB1)ØB2)ØB3)Ø………Bn).

And sequential thickening as,

AʘB=(((AʘB1)ʘB2)ʘB3)ʘ………Bn).

The process to thin image A by B1


Dilation Almost similar to dilation process, the
erosion process will move the structuring
Dilation is a process in which the binary element from left to right and up to
image is expanded from its original shape. bottom.
The way the binary image is expanded is
determined by the structuring element. At the centre position, indicated by the
centre of the structuring element, the
This structuring element is smaller in size process will look for whether there is a
as compared to the image itself and complete overlap with the structuring
normally the size used for the structuring element or not. If there is no complete
element is 3x3. overlapping then centre pixel indicated by
the centre of the structuring element will
The dilation process is similar to the be set white or zero.
convolution process i.e. the structuring
element is reflected and shifted from left to Let us define X as the reference binary
right and from top to bottom and at each image and B as the structuring element.
shift, the process will look for any Erosion is defined by the equation
overlapping similar pixels with structuring X xnor B = { Z | [(Ḃ)z x]
element and that at binary image. If there
exists an overlapping then pixels under the The above equation states that the outcome
centre position of the structuring element element Z is considered only when the
will be turned to 1 or black structuring element is a subset or equal to
binary image X
Let us define X as reference image and B
as the structuring element. The dilation Dilation Erosion Best operation
operation is defined as
X xor B={Z|[(Ḃ)znx]} <1> Opening

Where Ḃ is the image B rotated about the 1) Opening is based on the morphological
origin. operations, erosion and dilation.

Above equation states that when the image 2) Opening smoothest the inside of the
X is dilated by the structuring element B, object contour, brakes narrow strips and
the outcome element Z would be that there eliminates thin portion of the image. It is
will be at least 1 element in B that done by 1st applying erosion and then
intersects in X dilation operations on the image.

Erosion 3) The opening operation is used to


remove noise and CCD detected in the
Erosion is the contour-process of dilation. image.
If dilation enlarges on image then erosion
shrinks the image. 4) The opening filters details and
simplifies images by rounding corners
The way the images shrunk is determined from inside objects where the kernel uses
by the structuring element. fits.

The structuring element is normally 5) The opening process can be


smaller than the image with a 3x3 size. mathematically represented as X.B = (X
exnor B) exor B Where X is an input
image and B is the structuring element.
<2> Closing

1) The closing operation is the opposite of


the opening operation. It is a dilation
operation followed by an erosion
operation.

2) The closing operation fills the small


holes and gaps in a single-pixel object.’

3) It is has the same effect of an opening


operation, in that it smoothes contours and
maintains shapes and sizes of object.

4) The closing process can be


mathematically represented as X.B = (X
exor B) exnor B Where X is an input
image and B is the structuring element.

5) Closing protects coarse structure, closes


small gapes and round off concave
corners.
Boundary Extraction:

If A is an image and structuring element is


B then Boundary Extraction can be given
as,

Boundary (A) = A - (A Ɵ B)

It means subtracting the erode image of A


from the original Image. Let A =
Hence, it would give a pixel difference.

Region Filling:

It fills the hollow portion of the image.

Xk=(Xk−1⊗B)∩ACk=1,2,3,….

To start the procedure of region filling,we


start with a pixel p and assign a value 1 to
it.
If B=
Then apply the above formula to it,X0=p

and B is the structuring element.

Then AƟB would be same as A except one


pixel, A Ɵ B =

Consider the example A=

Now Boundary (A) =

We start with pixel p inside the


boundary.Let p=1

Therefore X0=p
Now according to formula,
Xk=(Xk−1⊗B)∩ACk=1,2,3,….

Therefore, X_1=(X_0 \otimes B)∩A^C i.e.


X1 is X0

dilated by B which is then intersected by


the complement of A Similarly,

X2=(X1⊗B)∩AC

We continue to use the formula till


Xk=Xk−1.

X1=(X0⊗B)∩AC

Similarly,k=1,2,3…..,we get the final


output

X5=(X4⊗B)∩AC

Since,X5=X4(Xk=Xk−1.)

we stop the algorithm here.

Therefore,Xk=X4
The final step is finding the union of
image A and X4

AUXk=A∩X4
i. The segmentation which is carried out examined depending on the type of
based on similarities in the given image is connectivity assumed (4 connectivity or 8
known as region based segmentation. connectivity)

ii. The regions that are formed using this iv. The neighboring pixel is accepted in the
method have the following properties same region as (x1,y1) if they together
satisfy the homogeneity property of a
a. The sum of all the regions is equal to the region. That is, both of them satisfy a
whole image. predefined condition of the region.

b. Each region is contiguous and v. Once a new pixel say (x2,y2) is


connected accepted as a member of the current
region, the neighbors of this new pixel are
c. A pixel belongs to a single region only, examined to increase the region further.
hence there is no overlap of pixels.
vi. This procedure goes on until no new
d. Each region must satisfy some pixel is accepted. All the pixels of the
uniformity condition current region are given a unique label.
Now a new seed is chosen and the same
e. Two adjacent regions do not have procedure is repeated. This procedure is
anything in common. repeated till the time all the pixels are
assigned to some group or the other.
iii. Region based segmentation can be
carried out in four different ways : (II) Region Splitting

(I) Region Growing i. In region splitting, we try to satisfy the


homogeneity property where pixels that
(II) Region Splitting are similar are grouped together.

(III) Region merging ii. If the grey levels present in the region
do not satisfy the property, we divide the
(IV) Split and merge region into four equal quadrants. If the
property is satisfied, we leave the region as
Each of them is explained below it is.

(I) Region Growing iii. This is done repeatedly, until all the
regions satisfy the given property.
i. The procedure in which pixels are
grouped into larger regions based on some iv. The splitting technique is shown below
predefined conditions is known as region
growing

ii. The basic approach is to pick a seed


point (Starting pixel) and grow regions
from this seed pixel v. In the above example, the entire image
will be represented by R, this R is the
iii. Let us pick up a random pixel (x1,y1) parent node, it is split into four leaf nodes
from the image that needs to be R1, R2, R3 and R4. Of these leaf nodes
segmented. This pixel is called the seed only R4 does not contain pixels which
pixel. The nearest neighbors of (x1,y1) are satisfy some common property, hence R4
is split into four regions R41, R42, R43 v. Such a technique where the above
andR44. combination is used is known as Split and
Merge technique.
vi. Now if all the pixels in a particular
region are satisfying some common
property in that region, then splitting is
stopped. This is how region splitting
works.

(III) Region Merging

i. The region merging method, is exactly


opposite to the region splitting method

ii. In this method, we start from the pixel


level and consider each of them as a
homogeneous region. At any level of
merging we check if four adjacent
homogeneous regions arranged in a 2 x 2
manner, together satisfy the homogeneity
property.

iii. If the property is satisfied, then the


pixels are merged to form a bigger region,
otherwise the regions are left as they are.

(IV) Split and Merge

i. Region splitting and region merging


were explained above, in region splitting
we start with the whole image and split the
image into four quadrants. We continue
splitting each quadrant further, until all the
sub-regions satisfy the predefined
homogeneity property.

ii. In Region merging each pixel is taken


as a small region, we merge small regions
into larger regions if they satisfy the
homogeneity property.

iii. If the homogeneous regions are small,


region merging technique is superior and if
the regions are large, region splitting is
preferred.

iv. Now, in most applications a


combination of both, region splitting and
region merging is used.

You might also like