Skip to content
Advertisement

Is it possible to create a random shape on an image in python?

I need to create some spots on an image. The spots are of irregular shape (mainly I was trying to add a big circle then trying to add smaller circles on the edges of the big circle so it gets an “irregular” circular shape). Here I just showed one circle in the example. As I have a directory full of images, the size, the location, and the number of the spots need to be varied for every image. What I tried is given here:

JavaScript

This is the image I get

But I want to add something like this. I did it with paint. This is the thing I want to add on the image

Advertisement

Answer

Here is the full code to add the white blobs with a black border onto some image in Python/OpenCV.

Input:

enter image description here

JavaScript

Result1 (white blobs):

enter image description here

Result2 (white blobs with black border):

enter image description here

Result3 (noise blobs with black border):

enter image description here

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement