Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

[SOLVED] How to compare two images pixel by pixel, and exlude certain pixels from the comparison?

$
0
0
So we have this 2 QImages     QImage screenshot_Qimage;     QImage previous_QImage; This code runs perfectly and completed in only 4 milleseconds:         if(screenshot_Qimage.operator ==(previous_QImage))         {             qDebug() << "Same images";         } But what if i want to exlude certain pixels? Lets say i dont want from it to compare the pixel(50,50) . I got no other choise but to compare those 2 images pixel by pixel(am i right?).. So the code below compares every pixel of these 2 images: if(screenshot_Qimage.width()==previous_QImage.width() && screenshot_Qimage.height()==previous_QImage.height())         {             bool something_is_not_the_same=false;             int screenshot_Qimage_width=screenshot_Qimage.width();             int screenshot_Qimage_height=screenshot_Qimage.height();             for(int i=1; i<screenshot_Qimage_width; i++)             {                 if(something_is_not_the_same)                     break;                 for(int j=1; j<screenshot_Qimage_height; j++)                 {                     if(QColor(screenshot_Qimage.pixel(i,j)).name()!=QColor(previous_QImage.pixel(i,j)).name())                     {                         qDebug() << "different pixel detected";                         something_is_not_the_same=true;                         break;                     }                 }             }         } Well it takes 3 seconds to be executed, :/

Viewing all articles
Browse latest Browse all 18427

Trending Articles