Skip to content

Commit 33db98d

Browse files
v2.3: added Clear and GrabCut functions
1 parent 399a1cc commit 33db98d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

mainwindow.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,10 +1670,11 @@ void MainWindow::mousePressEvent(QMouseEvent *eventPress) // event triggered by
16701670
else if ((mouseButton == Qt::RightButton) & (pos.x >= 0) & (pos.x < image.cols)
16711671
& (pos.y >= 0) & (pos.y < image.rows)) { // right mouse button = transparent/black pixel
16721672
Mat1b mask_tmp = Mat::zeros(image.rows, image.cols, CV_8UC1);
1673-
if (ui->horizontalSlider_draw_size->value() == 0)
1674-
mask.at<Vec3b>(pos.y, pos.x) = Vec3b(255, 255, 255); // draw pixel in mask
1673+
if (ui->horizontalSlider_draw_size->value() == 0) {
1674+
mask_tmp.at<uchar>(pos.y, pos.x) = 255; // draw pixel in mask
1675+
}
16751676
else // circle
1676-
circle(mask_tmp, pos, ui->horizontalSlider_draw_size->value() + 1, Vec3b(255, 255, 255), -1, LINE_8);
1677+
circle(mask_tmp, pos, ui->horizontalSlider_draw_size->value() + 1, 255, -1, LINE_8);
16771678
draw_cell_mask_save.copyTo(mask, mask_tmp);
16781679
}
16791680

@@ -1764,10 +1765,11 @@ void MainWindow::mouseMoveEvent(QMouseEvent *eventMove) // first mouse click has
17641765
else if ((mouseButton == Qt::RightButton) & (pos.x >= 0) & (pos.x < image.cols)
17651766
& (pos.y >= 0) & (pos.y < image.rows)) { // right mouse button pixel unset
17661767
Mat1b mask_tmp = Mat::zeros(image.rows, image.cols, CV_8UC1);
1767-
if (ui->horizontalSlider_draw_size->value() == 0)
1768-
mask.at<Vec3b>(pos.y, pos.x) = Vec3b(255, 255, 255); // draw pixel in mask
1768+
if (ui->horizontalSlider_draw_size->value() == 0) {
1769+
mask_tmp.at<uchar>(pos.y, pos.x) = 255; // draw pixel in mask
1770+
}
17691771
else // circle
1770-
circle(mask_tmp, pos, ui->horizontalSlider_draw_size->value(), Vec3b(255, 255, 255), -1, LINE_8);
1772+
circle(mask_tmp, pos, ui->horizontalSlider_draw_size->value(), 255, -1, LINE_8);
17711773
draw_cell_mask_save.copyTo(mask, mask_tmp);
17721774
}
17731775

0 commit comments

Comments
 (0)