Hello, I have a binary edge detected picture(used Canny edge detection method), now I would like to filter out small or not required edges ( by length or shape or number of pixels) in python, does anyone have any suggestions ?
Muhammad Ali very thanks to your answer, thats not what I wanted, I do not want to filter out images in the canny process, later after canny I would like to reduce smaller edges as I desired, the most important for me is since it is a liquid I am processing I would like to see the water drops, but filtering out noises that is not desirable. if I want to do it in canny it does the filter for everything.
To remove small features, you can use "connectedComponentsWithStats" from OpenCV. It allows you to calculate stats over pixels, like component size (cf. https://stackoverflow.com/questions/47055771/how-to-extract-the-largest-connected-component-using-opencv-and-python).
This part of image processing that allows you to crop or remove unnecessary parts of an image is called "image segmentation" because it segment/cut/crop the needed parts of the image and in some cases segment the foreground objects from the background. You can search for image segmentation in Python. And you will find many.
Keep in mind that when working with images, OpenCV (C++ based) is way better than Python. But, it is worth looking at Python resources as well.
Here are some top image segmentation methods using Python:
One of my favorite methods for image segmentation is the watershed segmentation method. It is worth checking out and try deploying for your work. Check this link out:
1) What is the dimension of your data set. Is it 2D or 3D?
2) Are the edges isolated or connected with desired edges?
3) It would be much better if you could share a sample image you are dealing with.
As far as I can understand your question, depending upon the type of edges that needs to be trimmed, following scikit-image module functions best suits to solve your problem in Python.
I have attached a sample in my message, if you open it you can see from right top of the image I have many noises edges ( already filtered out many of small detected edges but these are consistent and effect the quality of my edge tracing system )
, if I push too much on filtering noise I will lose valuable edges, I have managed to remove some but still i have small connected edges, I have also tried to sharpen the edges before canny edge detection and also filter out noise, unsuccessful unfortunately, I have tried to filter out dynamic and static but since my image frame was also moving again failed. but thanks for suggestion.