Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- do{
- dir = dir % 8;
- int r = pcurrent.x + di[dir];
- int c = pcurrent.y + dj[dir];
- //check if r and c are in the image coordinate space;
- if (r >= 0 && c >= 0 && r <= src->rows && c <= src->cols) {
- //check if the pixel is black
- if (src->at<uchar>(r, c) == 0) {
- //if black, we save the p0->p1, and p1 = new point indentified;
- plast = pcurrent;
- pcurrent = Point(r, c);
- directions.push_back(dir);
- coloredBorder.at<Vec3b>(r, c) = Vec3b(0, 0, 255);
- //we find the new direction to search the next pixel based on its parity;
- if (dir % 2) {
- dir = (dir + 6) % 8;
- }
- else {
- dir = (dir + 7) % 8;
- }
- }
- else {
- //if a black pixel is not found, we search to the next neighbours in the neighbourhood;
- dir++;
- }
- }
- else {
- //not in coordinate space, but we must increment dir;
- dir++;
- }
- conditionSatisfied = pcurrent.x == p1.x && pcurrent.y == p1.y && plast.x == p0.x && plast.y == p0.y;
- }while (!conditionSatisfied);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement