// funkcja filtrujaca chmure punktow
void FilterPCL::FilterScene(Point3D::Cloud& input, Point3D::Cloud& output_cloud) const {
    float Y ;
    float Cb;
    float Cr;

    int i_out=0;
    Point3D temp;
    Point3D output;
    Point3D::Cloud temp_cloud;
    int av=0;

    // filtr w przestrzeni kolorow YCbCr
    for(size_t i=0;i<input.size();i++){
        //konwersja przestrzeni RGB na YCbCr
        Y=0.299*(float)input[i].colour.r+0.587*(float)input[i].colour.g+0.114*(float)input[i].colour.b;
        Cb=128-0.168935*(float)input[i].colour.r+0.331665*(float)input[i].colour.g+0.50059*(float)input[i].colour.b;
        Cr=128+0.499813*(float)input[i].colour.r-0.418531*(float)input[i].colour.g-0.081282*(float)input[i].colour.b;
        if(Cb>=80 && Cb <=135 && Cr>=131 && Cr<=185){ //przedzial kolorow dla skory w przestrzeni YCbCr
         // if(Cb>=77 && Cb <=127 && Cr>=133 && Cr<=173){ //przedzial kolorow dla skory w przestrzeni YCbCr
            temp.colour.r=input[i].colour.r;
            temp.colour.g=input[i].colour.g;
            temp.colour.b=input[i].colour.b;
            temp.position.x=input[i].position.x;
            temp.position.y=input[i].position.y;
            temp.position.z=input[i].position.z;
            av+=int(temp.position.z*1000); //srednia wartosc glebii
            temp_cloud.push_back(temp);
            i_out++; //inkrementacja licznika elementów chmury wyjsciowej
        }
    }
  
    av=(float)av/(float)i_out; //srednia wartosc glebii
	i_out=0;


    //filtracja wg glebii
    for(int i=0;i<temp_cloud.size();i++){
        if (abs(1000*temp_cloud[i].position.z-av)<300){ // w milimetrach
            output.colour.r=temp_cloud[i].colour.r;
            output.colour.g=temp_cloud[i].colour.g;
            output.colour.b=temp_cloud[i].colour.b;
            output.position.x=temp_cloud[i].position.x;
            output.position.y=temp_cloud[i].position.y;
            output.position.z=temp_cloud[i].position.z;


            if (std::isnan(output.position.x) == false)
                output_cloud.push_back(output);


        }
    }


}
Beispiel #2
0
void FilterPCL::FilterScene(Point3D::Cloud& input, Point3D::Cloud& output) const {
    float Y ;
    float Cb;
    float Cr;
    // filtr w przestrzeni kolorów YCbCr
    for(int i=0; i<input.size(); i++) {
        Y=0.299*(float)input[i].colour.r+0.587*(float)input[i].colour.g+0.114*(float)input[i].colour.b;
        Cb=128-0.168935*(float)input[i].colour.r-0.331665*(float)input[i].colour.g+0.50059*(float)input[i].colour.b;
        Cr=128+0.499813*(float)input[i].colour.r-0.418531*(float)input[i].colour.g-0.081282*(float)input[i].colour.b;
        if(Cb>=77 && Cb <=127 && Cr>=133 && Cr<=173) {
            output[i].colour.r=255;
            output[i].colour.g=255;
            output[i].colour.b=255;
        }
    }

    // dzia³anie na pliku z dysku

    /*
    float Y ;
    float Cb;
    float Cr;
    unsigned char r;
    unsigned char g;
    unsigned char b;

    bitmap_image image("sciezka_pliku");
    const unsigned int height = image.height();
    const unsigned int width  = image.width();

    for (std::size_t y = 0; y < height; ++y)
       {
          for (std::size_t x = 0; x < width; ++x)
          {
             image.get_pixel(x,y,r,g,b);
             Y=0.299*r+0.587*g+0.114*b;
             Cb=128-0.168935*r-0.331665*g+0.50059*b;
             Cr=128+0.499813*r-0.418531*g-0.081282*b;
             // Y > 80, 85 < Cb < 135, and 135 < Cr < 180 // warianty przedzia³ów
             //  77 <= Cb <= 127, and 133 <= Cr <= 173
             if(Cb>=77 && Cb <=127 && Cr>=133 && Cr<=173)
                 image.set_pixel(x,y,255,255,255);
          }
       }

    image.save_image("sciezka_pliku_out");
    */

    // fragment testowy

    /*for(int i=0;i<input.size();i++){
        if(input[i].colour.r<150)
            output[i].colour.r=0;
    }*/

}