GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: No Line Numbers


Edge filter problem by Anonymous
1
 
    #define IMG(i,j,c) Edge[i*256+j][c]
                unsigned char  Edge[256*256][3]
    float V1,V2,V3;
    for(I=0;I<255;I++){
        for(int J=0;J<255;J++){
            V1=sqrt(IMG(I,J,0)*IMG(I,J,0)+IMG(I,J,1)*IMG(I,J,1)+IMG(I,J,2)+IMG(I,J,2));
            V2=sqrt((IMG(I,J,0)-IMG(I+1,J,0))*(IMG(I,J,0)-IMG(I+1,J,0))+
                    (IMG(I,J,1)-IMG(I+1,J,1))*(IMG(I,J,1)-IMG(I+1,J,1))+
                    (IMG(I,J,2)-IMG(I+1,J,2))*(IMG(I,J,2)-IMG(I+1,J,2)));

            V3=sqrt((IMG(I,J,0)-IMG(I,J+1,0))*(IMG(I,J,0)-IMG(I,J+1,0))+
                    (IMG(I,J,1)-IMG(I,J+1,1))*(IMG(I,J,1)-IMG(I,J+1,1))+
                    (IMG(I,J,2)-IMG(I,J+1,2))*(IMG(I,J,2)-IMG(I,J+1,2)));
            if(V2>=V1 || V3>=V1){
                IMG(I,J,0)=255;IMG(I,J,1)=255;IMG(I,J,2)=255;
            }else{
            IMG(I,J,0)=0;IMG(I,J,1)=0;IMG(I,J,2)=0;    
            }

        }
    }