Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

Search This Blog

Hit-or-Miss Transform in MATLAB with code


Binary hit-miss operationcollapse all in page

Syntax

BW2 = bwhitmiss(BW,SE1,SE2)

BW2 = bwhitmiss(BW,interval)

Description

BW2 = bwhitmiss(BW,SE1,SE2) performs the hit-miss operation defined by the structuring elements SE1 and SE2. The hit-miss operation preserves pixels in binary image BW whose neighborhoods match the shape of SE1 and don't match the shape of SE2.


This syntax is equivalent to imerode(BW,SE1) & imerode(~BW,SE2).


example

BW2 = bwhitmiss(BW,interval) performs the hit-miss operation defined in terms of a single array, called an interval. An interval is an array whose elements are 1, 0, or -1. The 1-valued elements make up the domain of SE1, the -1-valued elements make up the domain of SE2, and the 0-valued elements are ignored.


This syntax is equivalent to bwhitmiss(BW,interval==1,interval==-1).


%Code:

 

clc

clear all

close all

warning off

A=imread('text.png');

figure;

imshow(A);

title('Original Image');

B=imcrop(A);

se1=B;

se2=~B;

bw=bwhitmiss(A,se1,se2);

[i,j]=find(bw==1);

figure;

g=strel('disk',15);

bw=imdilate(bw,g);

imshow(bw);

title('Output of Hit and Miss Transform');

 

Video explanation below. 



Join us on Telegram: https://t.me/matlabcastor

No comments

Popular Posts