1 | initial version |
You can use the Marching Squares algorithm to create the level set contour. Here is some code that I wrote some time ago:
https://github.com/sjhalayka/Marching-Squares
The code uses the OpenGL/GLUT libraries to draw the image and the contour.
Best of luck.
2 | No.2 Revision |
You can use the Marching Squares algorithm to create the level set contour. Here is some C++ code that I wrote some time ago:
https://github.com/sjhalayka/Marching-Squares
The code uses the OpenGL/GLUT libraries to draw the image and the contour.
Best of luck.luck. If you like this answer, please mark the answer as correct.
3 | No.3 Revision |
You can use the Marching Squares algorithm to create the level set contour. contour(s). Here is some C++ code that I wrote some time ago:
https://github.com/sjhalayka/Marching-Squares
The code uses the OpenGL/GLUT libraries to draw the image and the contour.
Best of luck. If you like this answer, please mark the answer as correct.
4 | No.4 Revision |
You can use the Marching Squares algorithm to create the level set contour(s). Here is some C++ code that I wrote some time ago:
https://github.com/sjhalayka/Marching-Squares
The code uses the OpenGL/GLUT libraries to draw the image and the contour.contour(s).
Best of luck. If you like this answer, please mark the answer as correct.
5 | No.5 Revision |
You can use the Marching Squares algorithm to create the level set contour(s). Here is some C++ code that I wrote some time ago:
https://github.com/sjhalayka/Marching-Squares
The code uses the OpenGL/GLUT libraries to draw the image and the contour(s).
Best of luck. If you like this answer, please mark the answer as correct.
Source image:
Contours image:
6 | No.6 Revision |
You can use the Marching Squares algorithm to create the level set contour(s). Here is some C++ code that I wrote some time ago:
https://github.com/sjhalayka/Marching-Squares
The code uses the OpenGL/GLUT libraries to draw the image and the contour(s).
Best of luck. If you like this answer, please mark the answer as correct.
There is also the threshold and findContours functions, which can be used to get the level set, if you find that Marching Squares is too complicated:
https://docs.opencv.org/3.3.1/d4/d73/tutorial_py_contours_begin.html
Source image:
Contours image:
7 | No.7 Revision |
You can use the Marching Squares algorithm to create the level set contour(s). Here is some C++ code that I wrote some time ago:
https://github.com/sjhalayka/Marching-Squares
The code uses the OpenGL/GLUT libraries to draw the image and the contour(s).
Best of luck. If you like this answer, please mark the answer as correct.
There is also the threshold and findContours functions, which can be used to get the level set, if you find that Marching Squares is too complicated:
https://docs.opencv.org/3.3.1/d4/d73/tutorial_py_contours_begin.html
Source image:
Contours image:
#pragma comment(lib, "opencv_world340.lib")
#include <opencv2/opencv.hpp>
using namespace cv;
#include <iostream>
using namespace std;
int main(void)
{
Mat cat_img = imread("cat.png", CV_LOAD_IMAGE_GRAYSCALE);
threshold(cat_img, cat_img, 127, 255, THRESH_BINARY);
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
findContours(cat_img, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE, Point(0, 0));
Mat cat_contours = Mat::zeros(cat_img.size(), CV_8UC3);
for (size_t i = 0; i < contours.size(); i++)
drawContours(cat_contours, contours, (int)i, Scalar(255, 0, 0), 2, 8, hierarchy, 0, Point());
imshow("cat img", cat_contours);
waitKey(0);
destroyAllWindows();
return 0;
}
8 | No.8 Revision |
You If you want to do it yourself from the ground up, you can use the Marching Squares algorithm to create the level set contour(s). Here is some C++ code that I wrote some time ago:
https://github.com/sjhalayka/Marching-Squares
The code uses the OpenGL/GLUT libraries to draw the image and the contour(s).
Best of luck. If you like this answer, please mark the answer as correct.
There is also the threshold and findContours functions, which can be used to get the level set, if you find that Marching Squares is too complicated:
#pragma comment(lib, "opencv_world340.lib")
#include <opencv2/opencv.hpp>
using namespace cv;
#include <iostream>
using namespace std;
int main(void)
{
Mat cat_img = imread("cat.png", CV_LOAD_IMAGE_GRAYSCALE);
threshold(cat_img, cat_img, 127, 255, THRESH_BINARY);
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
findContours(cat_img, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE, Point(0, 0));
Mat cat_contours = Mat::zeros(cat_img.size(), CV_8UC3);
for (size_t i = 0; i < contours.size(); i++)
drawContours(cat_contours, contours, (int)i, Scalar(255, 0, 0), 2, 8, hierarchy, 0, Point());
imshow("cat img", cat_contours);
waitKey(0);
destroyAllWindows();
return 0;
}
9 | No.9 Revision |
If you want to do it yourself from the ground up, you can use the Marching Squares algorithm to create the level set contour(s). Here is some C++ code that I wrote some time ago:
https://github.com/sjhalayka/Marching-Squares
The code uses the OpenGL/GLUT libraries to draw the image and the contour(s).
Best of luck. If you like this answer, please mark the answer as correct.
There is also the OpenCV threshold and findContours functions, which can be used to get the level set, if you find that Marching Squares is too complicated:
#pragma comment(lib, "opencv_world340.lib")
#include <opencv2/opencv.hpp>
using namespace cv;
#include <iostream>
using namespace std;
int main(void)
{
Mat cat_img = imread("cat.png", CV_LOAD_IMAGE_GRAYSCALE);
threshold(cat_img, cat_img, 127, 255, THRESH_BINARY);
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
findContours(cat_img, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE, Point(0, 0));
Mat cat_contours = Mat::zeros(cat_img.size(), CV_8UC3);
for (size_t i = 0; i < contours.size(); i++)
drawContours(cat_contours, contours, (int)i, Scalar(255, 0, 0), 2, 8, hierarchy, 0, Point());
imshow("cat img", cat_contours);
waitKey(0);
destroyAllWindows();
return 0;
}