Skip to content

Commit

Permalink
fix #7 #31 fix the result on view when the check box "keep border pro…
Browse files Browse the repository at this point in the history
…vide by the watershed" is checked. see #31 for more information.
  • Loading branch information
abreheret committed Feb 15, 2019
1 parent 413e622 commit ef64006
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/image_canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ void ImageCanvas::saveMask() {
_mask.id.save(_mask_file);
if (!_watershed.id.isNull()) {
QImage watershed = _watershed.id;
if (!_ui->checkbox_border_ws->isChecked()) {
watershed = removeBorder(_watershed.id, _ui->id_labels);
}
// if (!_ui->checkbox_border_ws->isChecked()) {
// watershed = removeBorder(_watershed.id, _ui->id_labels);
// }
watershed.save(_watershed_file);
QFileInfo file(_img_file);
QString color_file = file.dir().absolutePath() + "/" + file.baseName() + "_color_mask.png";
Expand Down
10 changes: 7 additions & 3 deletions src/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ void MainWindow::changeLabel(QListWidgetItem* current, QListWidgetItem* previous
}

void MainWindow::runWatershed(ImageCanvas * ic) {
ic->setWatershedMask(watershed(ic->getImage(), ic->getMask().id));
QImage iwatershed = watershed(ic->getImage(), ic->getMask().id);
if (!checkbox_border_ws->isChecked()) {
iwatershed = removeBorder(iwatershed, id_labels);
}
ic->setWatershedMask(iwatershed);
checkbox_watershed_mask->setCheckState(Qt::CheckState::Checked);
ic->update();
}
Expand Down Expand Up @@ -202,7 +206,7 @@ void MainWindow::updateConnect(const ImageCanvas * ic) {
connect(undo_action, SIGNAL(triggered()), ic, SLOT(undo()));
connect(redo_action, SIGNAL(triggered()), ic, SLOT(redo()));
connect(save_action, SIGNAL(triggered()), ic, SLOT(saveMask()));
connect(checkbox_border_ws, SIGNAL(clicked()), ic, SLOT(update()));
connect(checkbox_border_ws, SIGNAL(clicked()), this, SLOT(runWatershed()));

}

Expand All @@ -217,7 +221,7 @@ void MainWindow::allDisconnnect(const ImageCanvas * ic) {
disconnect(undo_action, SIGNAL(triggered()), ic, SLOT(undo()));
disconnect(redo_action, SIGNAL(triggered()), ic, SLOT(redo()));
disconnect(save_action, SIGNAL(triggered()), ic, SLOT(saveMask()));
disconnect(checkbox_border_ws, SIGNAL(clicked()), ic, SLOT(update()));
disconnect(checkbox_border_ws, SIGNAL(clicked()), this, SLOT(runWatershed()));
}

ImageCanvas * MainWindow::newImageCanvas() {
Expand Down
9 changes: 7 additions & 2 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ void idToColor(const QImage &image_id, const Id2Labels& id_label, QImage *result
*pix = label->color.red(); pix++;
*pix = label->color.green(); pix++;
*pix = label->color.blue();
}
} else {
pix = &line_out[x];
pix[0] = 255;
pix[1] = 255;
pix[2] = 255;
}
}
}
}
Expand Down Expand Up @@ -105,7 +110,7 @@ cv::Mat convertMat32StoRGBC3(const cv::Mat& mat) {
QImage watershed(const QImage& qimage, const QImage & qmarkers_mask) {
cv::Mat image = qImage2Mat(qimage);
cv::Mat markers_mask = qImage2Mat(qmarkers_mask);
cv::Mat markers(markers_mask.size(), CV_32S);
cv::Mat markers = cv::Mat::zeros(markers_mask.size(), CV_32S);
for (int y = 0; y < markers_mask.rows; y++) {
int* mark = markers.ptr<int>(y);
cv::Vec3b* mask = markers_mask.ptr<cv::Vec3b>(y);
Expand Down

0 comments on commit ef64006

Please sign in to comment.