For later object detection it is necessary to remove the background and other information from a depth picture. The idea is based on examining individual pixels on the picture, getting the depth value and, based on the depth, painting the pixels in another color. Two for loops run to the picture size through an individual pixel in an x and y direction. In this frame we can acquire information about the pixel depth, following is the condition execution. The condition is to keep the depth information in the range from 0.4 to 2 m.

The problem in my algorithm is, that the opencv core crashes, writes core dumped (Segmentation fault (core dumped)) and in addition reports that the variables are out of the given area.

Print: .... X: 6 Y: 1 Depth: 2896 X: 7 Y: 1 Depth: 2884 X: 8 Y: 1 Depth: 2896 X: 1 Y: 1 Depth: 3351 X: 2 Y: 1 Depth: 3401 X: 1 Y: 1 Depth: 2921 X: 2 Y: 1 Depth: 2872 X: 3 Y: 1 Depth: 2860 X: 4 Y: 1 Depth: 2848 X: 5 Y: 1 Depth: 2860 X: 1 Y: 1 Depth: 3165 X: 2 Y: 1 Depth: 3093 X: 3 Y: 1 Depth: 2946 X: 4 Y: 1 Depth: 2946 X: 5 Y: 1 Depth: 2884 X: 6 Y: 1 Depth: 2860 X: 7 Y: 1 Depth: 2884 (stay in this forever loop) Segmentation fault (core dumped)

My code is:

```
for(uint16_t y = 1; y <= _depth_intrin.height; y++){
for(uint16_t x = 1; x <= _depth_intrin.width; x++){
depth_value = depth16.at<uint16_t>(x, y);
if(depth_value == NULL){
return 0;
}
if(depth_value >= 2000){
depth16.at<cv::Vec3b>(cv::Point(x, y)) = 255;
}
if(depth_value <= 300){
depth16.at<cv::Vec3b>(cv::Point(x, y)) = 255;
}
cout << "X: " << x << " Y: " << y << endl;
cout << "Depth: " << depth_value << endl;
depth_value = 0;
}
}
```

Where I have a problem ?