It seems that you need the appearance of the image to be filled with black, because this makes it easier to identify the eggs, as they will be isolated in white.
But what if parasitic eggs magically looked blue? I will explain this in a second, but this approach will free you from the burden of clicking on the image every time you need a new sample for analysis.
I wrote an answer in C ++, but if you follow what the code does, I'm sure you can quickly translate it into Python.
#include <iostream> #include <vector> #include <opencv2/highgui.hpp> #include <opencv2/imgproc.hpp> int main(int argc, char* argv[]) { // Load input image (3-channel) cv::Mat input = cv::imread(argv[1]); if (input.empty()) { std::cout << "!!! failed imread()" << std::endl; return -1; } // Convert the input to grayscale (1-channel) cv::Mat grayscale = input.clone(); cv::cvtColor(input, grayscale, cv::COLOR_BGR2GRAY);
What shades of gray are as follows:

What circle_shape looks like :

output displayed in the window:

The advantage of this solution is that the user does not need to interact with the application to facilitate the detection of eggs, as they are already painted in blue.
After that, other operations can be performed using output , for example cv::inRange() to isolate colored objects from the rest of the image.
So, for the sake of completion, I will add a few more lines of text / code to demonstrate what you could do from now on to completely isolate the eggs from the rest of the image:
At this point, blue_pixels_only looks like :

// Get rid of pixels on the edges of the shape int erosion_type = cv::MORPH_RECT; // MORPH_RECT, MORPH_CROSS, MORPH_ELLIPSE int erosion_size = 3; cv::Mat element = cv::getStructuringElement(erosion_type, cv::Size(2 * erosion_size + 1, 2 * erosion_size + 1), cv::Point(erosion_size, erosion_size)); cv::erode(blue_pixels_only, blue_pixels_only, element); cv::dilate(blue_pixels_only, blue_pixels_only, element); cv::imshow("Eggs", blue_pixels_only); cv::imwrite("blue_pixels_only.png", blue_pixels_only);
At this point, blue_pixels_only looks like :
