Learn R Programming

KoulMde (version 3.2.1)

GetSegImage: Perform image segmentation

Description

Seperate an area of white pixels from a given image when there is some noise.

Usage

GetSegImage(ImgMat, p1, p2)

Arguments

ImgMat

- a matrix whose entries are pixel values of the image.

p1

- a known value of white pixel (usually 1).

p2

- a known value of black pixel (usually 0).

Value

A list of information of a segmented image.

  • SegImgMat - a matrix as a result of the image segmentation.

  • Estimated_S1 - an n1x2 matrix whose entries denote estimated coordinates of white pixels, corresponding to p1.

  • Estimated_S2 - an n2x2 matrix whose entries denote estimated coordinates of black pixels, corresponding to p2.

Examples

Run this code
# NOT RUN {

######## Generate a 10x10 black-and-white rectangle image with some noise
nx=10
ny=10
Type=1
bNoise=TRUE
sig_noise=0.1
lst = GenImg(nx,ny,Type, bNoise, sig_noise)
ImgMat = lst$ImgMat
image(ImgMat, axes = FALSE, col = grey(seq(0, 1, length = 256)))

######## Perform image segmentation
p1=1     ### value of a white pixel
p2=0     ### value of a black pixel


lst = GetSegImage(ImgMat, p1, p2)
EstImgMat = lst$SegImgMat
image(EstImgMat, axes = FALSE, col = grey(seq(0, 1, length = 256)))


# }

Run the code above in your browser using DataLab