# Scattering or Pushing for Object Singulation in Cluttered Environment: Case Study with Soma Cube
## 4 Parameter Estimation and Simulator Based Dynamic Manipulation
### Quasi-Static Manipulation or Singulation by Pushing
#### 5.2.1 Image Segmentation  
In this paper, we have used the quasi static manipulation which is based on the image processing techniques. RealSense SR305 Depth Camera (Intel, California, USA) is used to take image and it provides highly accurate depth data in a wide variety of vision applications. First, we take an RGB image from the camera and converts it into an Hue, Saturation, Value (HSV) color space. When expressed  
Figure 8: Soma cube: seven blocks formation. (**a**) Virtual world Soma blocks: initial position, (**b**) Virtual world Soma blocks: final position after scattering, (**c**) Real world Soma blocks: initial position, (**d**) Real world Soma blocks: final position after scattering, (**e**) Prehensile manipulation after singulation of Soma blocks.  
Figure 9: Principal component analysis (PCA) based image segmentation.  
in the HSV color space, the brightness of the image may be less affected than the RGB color space. Thus, it allows effective judgement of the specific color. Next, the cubes were segmented according to the HSV range. For example, if the cube is in the red color, the area is set to 255, and in all other cases, it is set to 0. Since the Soma Cube blocks are of single color, segmentation is relatively easy on complex backgrounds. Accordingly, the results of segmentation for each color (i.e., for each piece) are stored for each image. The saved images are post-processed by closing technique to remove noise. The closing technique is to perform erosion immediately after dilation and return to the original image size, and the contour of the image is obtained as a result of each segmentation. Here, the image contour is a line connecting the edge borders of parts having the same color or the same intensity. Furthermore, the thickness of the contour is made thick so that the contours can overlap if there are adjacent cubes. Now we compare the images of each piece in pairs to find intersection (or overlapping) between two contours of two pieces. However, there are noises even in overlapped images. When the contoured area was smaller than a certain area threshold, additional processing is required, and the bottom point of the overlapped contour part was taken as the reference point to mark the arrow after applying principal component analysis (PCA) to the region of overlapping contour. Here, PCA is a method of finding the principal component of the distributed data and is used for reducing the dimensionality of datasets, increasing interpretability but at the same time minimizing information loss and the bottom point refers to the point with the highest value of the row of the image. 2D image coordinate consists of row and column and the origin is located at the upper left corner. In our system, the camera mounted manipulator takes a picture and then goes back to home position where it will follow the direction of the arrow to perform pushing. In our two-dimensional binary image, we obtain two vectors that best represent the \"255\" intensity region, where 255 is changed to 1 and refers to white color, and 0 refers to black color. The two vectors represent the longest axis with the largest variance of the region and the shorter axis with the second largest, among which we chose the longest axis as the direction of pushing vector. The end point of the overlapped contour part in the row direction was used as the center point. Moreover, considering the size of the gripper, the length of vector pointing the direction of pushing was increased by the length of end effector. So, we changed the start point and end point of the arrow to 3D coordinates of the camera point of view, respectively, and pushed it out using the gripper.