Solution:
There are
different ways to tackle this problem. First one should be aware that there are
two different methods of computing image objects distance. Center of Gravity
and Smallest Enclosing Rectangle. Scour the help doc to find what those two methods
are and choose the method you want. You can set up this in the beginning of your rule set using rule set options algorithm. Obviously you need to first create a feature ' Distance to' with the class you are interested in. Afterwards, we going to use "find domain extreme" algorithm for finding the closest object.
For this problem, i am going to use the same image that i used in the last blog. We are going use different concepts such as multi-threshold segmentation, variables, and PPO. For every blob, we will find a nearest blob in the image.Subsequently, we will export results as image so that you can see what is happening.
find domain extrema |
Steps:
- multi-threshold segmentation to get all blobs and classify as class1
- create variable to count loop ( it will be later use to export images with distinct names)
- Use PPO to loop through class1
- assign current object as curr_class
- update variable
- find domain extreme to find nearest blob that belong to class1
- export image
Project to find the nearest object |
Color: Red- Class 1
Color: Green:cur_class
Color :Magenta: near ( blob closest to cur-class)
gif demonstrating nearest object |