OpenCV Lections: 4. Working With The Channels, The Threshold Processing, Flood Fill
OpenCV Lections: 4. Working With The Channels, The Threshold Processing, Flood Fill
http://www.svi.nl/wikiimg/SeedAndThreshold_02.png
www.uralvision.blogspot.com [email protected]
USU / IMM Fall 2010
The format of the ABC
1. Function Name
2. What it does
3. For what it's used
4. Announcement and description of the parameter list
5. Example D:
- Working code cpp, which reads the image, which carries
processing and displays the picture on the screen or writes to a file using
function imwrite
- Input image (png or jpg)
- The result of (png or jpg)
General operations
over images
Common operations on images
void merge (Const vector <Mat> & mv, Mat & dst )
mv - the original set of 1-channel image
dst - the resulting color image
split and merge - an example
Task - the input color image swap places red and blue channel, and to calculate the 1-
channel image that represents the brightness.
threshold- Threshold
THRESH_BINARY
THRESH_BINARY_INV
THRESH_TRUNC
THRESH_TOZERO
THRESH_TOZERO_INV
Please note: We have identified just pixels "not" field. To find the coordinates of
the centers of balls and cue position - requires further processing.
Working with Regions
Working with Regions
floodFill- Allocation of connected regions
morphological operations
dilate - dilation(*)
erode - Erosion(*)
floodFill - description
Function floodFillprovides a fill area, starting from a pixel (x, y), with specified
boundaries shutdown
using a 4 - or 8 - adjacency pixels.
2. It can also be used to remove small noise on the binary image (in contrast to
the "erosion + dilation" - do not spoil the boundaries of larger areas).
3.If enhance overall box found in the area of 1 pixel on all sides and make the fill,
the way you can eliminate the internal hole in the area.
floodFill - a list of options
Announcement and description of the parameter list:
int floodFill(Mat & image, Point seed, Scalar newVal, Rect * rect= 0
Scalar loDiff= Scalar (), Scalar upDiff= Scalar (),
int flags= 4)
image - The input image, 1 - or 3-channel, 8 or 32-bit.
seed - Pixel, from which to start pouring
rect - Bounding box found by the field
loDiff, UpDiff - allowable difference with its neighbors
(Or - with embryonic pixel, if
flags | = FLOODFILL_FIXED_RANGE)
that is, a new pixel must satisfy valueNew
value - loDiff <= valueNew <= value + upDiff.
flags = 4 or 8 - connectivity.
const int minRectDim = 25; // Max and min size of the balls
const int maxRectDim = 35;
In this example, we considered the simplest method for finding the ball in the picture - by
analyzing the sizes of bounding boxes.
Such an analysis works on the assumption that the image no other sites with similar
bounding boxes.
1. To fill the interior area, select the path obtained by field and assess its areas of
convexity and concavity for the selection of balls.
2. Use template "round", which is applied to the obtained area and look for the best of its
location.
Homework
Practical task 1
- See the names on uralvision.blogspot.com
Practical task 2
- See text of split and merge.