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...
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;
}