[C++] Dostęp do wartości poszczególnych pixeli pliku graficznego
Ostatnio zmodyfikowano 2017-02-05 11:00
j23 |
» 2017-02-02 14:33:30 Dużo tych różnic? |
|
PanKowal Temat założony przez niniejszego użytkownika |
» 2017-02-02 20:39:52 Na przykład dla obrazu 155x303px (140895) wartości różnica jest w 3648. I dużo i nie, w każdym razie jest to na tyle dużo, że w późniejszym przetwarzaniu obrazu dostaję znacząco różniące się wyniki. |
|
j23 |
» 2017-02-03 10:34:59 Daj przykładowe wartości kolorów które się różnią. BTW, źle porównujesz bitmapy. Spróbuj tak: for( int i = 0; i < img.rows; ++i ) { int( * cols1 )[ 3 ] =( int( * )[ 3 ] ) tab[ i ]; int( * cols2 )[ 3 ] =( int( * )[ 3 ] ) tab2[ i ]; for( int j = 0; j < img.cols; ++j ) { if( memcpy( cols1[ j ], cols2[ j ], sizeof( int ) * 3 ) != 0 ) { std::cout << "Difference at position y=" << i << " x=" << j << "\n"; std::cout << cols1[ j ][ 0 ] << "\t" << cols2[ j ][ 0 ] << "\n"; std::cout << cols1[ j ][ 1 ] << "\t" << cols2[ j ][ 1 ] << "\n"; std::cout << cols1[ j ][ 2 ] << "\t" << cols2[ j ][ 2 ] << "\n"; } } } |
|
PanKowal Temat założony przez niniejszego użytkownika |
» 2017-02-03 12:14:19 Z powyżej funkcji wypisuje, że wszystko jest różne. Czy oby na pewno if jest dobry? Z tego co wyczytałem to memcpy zwraca wskaźnik przekazany przez pierwszy argument - czy można go porównać do 0? Aczkolwiek większej wiedzy w tym temacie mi brak. Jeśli chodzi o to porównanie, które ja napisałem to wartości różnią się: 0 zamiast 255 oraz 255 zamiast 0. Innych różnic nie zaobserwowałem. |
|
jankowalski25 |
» 2017-02-03 14:28:31 @j23: Nie chodzi przypadkiem o funkcję memcmp zamiast memcpy? |
|
j23 |
» 2017-02-03 14:29:27 @jankowalski25, dokładnie, chodzi o memcmp. |
|
PanKowal Temat założony przez niniejszego użytkownika |
» 2017-02-03 18:32:10 Wrzucam wynik działania ostatnich pixeli obrazu 155x303px: 255 0 255 0 Difference at position y = 119 x = 260 255 0 255 0 255 0 Difference at position y = 120 x = 81 255 0 255 0 255 0 Difference at position y = 120 x = 82 255 0 255 0 255 0 Difference at position y = 120 x = 104 255 0 255 0 255 0 Difference at position y = 120 x = 105 255 0 255 0 255 0 Difference at position y = 120 x = 106 255 0 255 0 255 0 Difference at position y = 120 x = 107 255 0 255 0 255 0 Difference at position y = 120 x = 108 255 0 255 0 255 0 Difference at position y = 120 x = 109 255 0 255 0 255 0 Difference at position y = 120 x = 175 255 0 255 0 255 0 Difference at position y = 120 x = 176 255 0 255 0 255 0 Difference at position y = 120 x = 177 255 0 255 0 255 0 Difference at position y = 120 x = 178 255 0 255 0 255 0 Difference at position y = 120 x = 179 255 0 255 0 255 0 Difference at position y = 120 x = 180 255 0 255 0 255 0 Difference at position y = 120 x = 181 255 0 255 0 255 0 Difference at position y = 120 x = 182 255 0 255 0 255 0 Difference at position y = 120 x = 183 255 0 255 0 255 0 Difference at position y = 120 x = 184 255 0 255 0 255 0 Difference at position y = 120 x = 185 255 0 255 0 255 0 Difference at position y = 120 x = 186 255 0 255 0 255 0 Difference at position y = 120 x = 187 255 0 255 0 255 0 Difference at position y = 120 x = 254 255 0 255 0 255 0 Difference at position y = 120 x = 256 255 0 255 0 255 0 Difference at position y = 120 x = 257 255 0 255 0 255 0 Difference at position y = 120 x = 258 255 0 255 0 255 0 Difference at position y = 121 x = 80 255 0 255 0 255 0 Difference at position y = 121 x = 81 255 0 255 0 255 0 Difference at position y = 121 x = 82 255 0 255 0 255 0 Difference at position y = 121 x = 104 255 0 255 0 255 0 Difference at position y = 121 x = 105 255 0 255 0 255 0 Difference at position y = 121 x = 106 255 0 255 0 255 0 Difference at position y = 121 x = 107 255 0 255 0 255 0 Difference at position y = 121 x = 108 255 0 255 0 255 0 Difference at position y = 121 x = 109 255 0 255 0 255 0 Difference at position y = 121 x = 178 255 0 255 0 255 0 Difference at position y = 121 x = 179 255 0 255 0 255 0 Difference at position y = 121 x = 180 255 0 255 0 255 0 Difference at position y = 121 x = 181 255 0 255 0 255 0 Difference at position y = 121 x = 182 255 0 255 0 255 0 Difference at position y = 121 x = 183 255 0 255 0 255 0 Difference at position y = 121 x = 184 255 0 255 0 255 0 Difference at position y = 121 x = 185 255 0 255 0 255 0 Difference at position y = 122 x = 80 255 0 255 0 255 0 Difference at position y = 122 x = 81 255 0 255 0 255 0 Difference at position y = 122 x = 105 255 0 255 0 255 0 Difference at position y = 122 x = 106 255 0 255 0 255 0 Difference at position y = 122 x = 107 255 0 255 0 255 0 Difference at position y = 122 x = 108 255 0 255 0 255 0 Difference at position y = 122 x = 109 255 0 255 0 255 0 Difference at position y = 123 x = 79 255 0 255 0 255 0 Difference at position y = 123 x = 80 255 0 255 0 255 0 Difference at position y = 123 x = 81 255 0 255 0 255 0 Difference at position y = 123 x = 107 255 0 255 0 255 0 Difference at position y = 123 x = 108 255 0 255 0 255 0 Difference at position y = 123 x = 109 255 0 255 0 255 0 Difference at position y = 123 x = 110 255 0 255 0 255 0 Difference at position y = 124 x = 79 255 0 255 0 255 0 Difference at position y = 124 x = 80 255 0 255 0 255 0 Difference at position y = 124 x = 81 255 0 255 0 255 0 Difference at position y = 124 x = 108 255 0 255 0 255 0 Difference at position y = 124 x = 109 255 0 255 0 255 0 Difference at position y = 124 x = 110 255 0 255 0 255 0 Difference at position y = 124 x = 111 255 0 255 0 255 0 Difference at position y = 125 x = 79 255 0 255 0 255 0 Difference at position y = 125 x = 80 255 0 255 0 255 0 Difference at position y = 125 x = 81 255 0 255 0 255 0 Difference at position y = 125 x = 108 255 0 255 0 255 0 Difference at position y = 125 x = 109 255 0 255 0 255 0 Difference at position y = 126 x = 77 255 0 255 0 255 0 Difference at position y = 126 x = 78 255 0 255 0 255 0 Difference at position y = 126 x = 79 255 0 255 0 255 0 Difference at position y = 126 x = 80 255 0 255 0 255 0 Difference at position y = 127 x = 79 255 0 255 0 255 0 licznik: 3172
|
|
j23 |
» 2017-02-03 20:20:33 Dziwne. Rozumiem, że to 255 na podanych pozycjach występować nie powinno? Może jest tak, że cv::imread przy czytaniu dokonuje jakiejś konwersji... Tylko po co?
A do czego Ci to porównywanie? |
|
1 « 2 » 3 |