You are on page 1of 5

Bài 2:

while (1) {
// Chuyen sang he mau HSV
Mat HSV;
cvtColor(src_resize, HSV, COLOR_BGR2HSV);
imshow("SOURCE IMAGE1", src_resize);

// Phat hien mau dua tren khoang gia tri tren Track_bar
Mat detection;
inRange(HSV, Scalar(Hue_Lower_Value, Saturation_Lower_Value, Value_Lower),
Scalar(Hue_Upper_Value, Saturation_Upper_Value, Value_Upper), detection);

// Phep mo de loai bo cac doi tuong nho tu tien canh


erode(detection, detection, getStructuringElement(MORPH_ELLIPSE, Size(9,
9)));
dilate(detection, detection, getStructuringElement(MORPH_ELLIPSE, Size(9,
9)));

//Phep đóng để lấp đầy các lỗ nhỏ tren tien canh


dilate(detection, detection, getStructuringElement(MORPH_ELLIPSE, Size(9,
9)));
erode(detection, detection, getStructuringElement(MORPH_ELLIPSE, Size(9,
9)));
// Hien thi anh nguon
imshow("SOURCE IMAGE", src_resize);
//Hien thi mau duoc phat hien
imshow("Detected Color", detection);

// neu nhan ESC thi thoat chuong trinh


if (waitKey(30) == 27) {
break;
}
}

Bài 3:
Bài 4:

You might also like