C++ program without Open CV and external libraries

Can anyone please tell me how to implement this code in C++ without OpenCV or external libraries …I am working on contour detection .This below code is for threshold.

#include"CImg.h"

#include<iostream>

#define cimg_use_jpeg

using namespace std;
using namespace cimg_library;

int main()

{
    CImg<unsigned char>Image = 

CImg<float>::get_load("inputImages/parrot.ppm"),res=Image.get_threshold(128, 255);
    
(Image, res.normalize(0, 255)).display();

return 0;
}

This is a small piece of code for findcontour() function to detect the contours in the image using opencv… which I need to implement without using opencv…

// detect the contours on the binary image using cv2.CHAIN_APPROX_NONE

vector<vector<Point>> contours;

vector<Vec4i> hierarchy;

findContours(thresh, contours, hierarchy, RETR_TREE, CHAIN_APPROX_NONE);

// draw contours on the original image

Mat image_copy = image.clone();

drawContours(image_copy, contours, -1, Scalar(0, 255, 0), 2);

imshow("None approximation", image_copy);

waitKey(0);

imwrite("contours_none_image1.jpg", image_copy);

destroyAllWindows();