Ask Your Question

Revision history [back]

int main() {
ifstream fs;
const int tailleImage=3073;

fs.open("F:\\Images\\cifar-10-batches-bin\\data_batch_1.bin",ios::binary);
if (!fs.is_open())
    return 0;
for (int indexImage=25;indexImage<50;indexImage++)
{
    fs.seekg(indexImage*tailleImage,ios::beg);
    char *data=new char[tailleImage];
    fs.read(data,tailleImage);

    Mat im(32,32,CV_8UC3);
    for (int i=0;i<im.rows;i++)
        for (int j=0;j<im.rows;j++)
            im.at<Vec3b>(i,j)=Vec3b(data[j+i*32],data[j+i*32+32*32],data[j+i*32+32*32*2]);
    imshow("CIFAR",im);
        waitKey(100);
}
return 0;
}

May be you should read a book about C++

int main() { ifstream fs; const int tailleImage=3073; tailleImage=3073;

fs.open("F:\\Images\\cifar-10-batches-bin\\data_batch_1.bin",ios::binary);
if (!fs.is_open())
    return 0;
for (int indexImage=25;indexImage<50;indexImage++)
{
    fs.seekg(indexImage*tailleImage,ios::beg);
    char *data=new char[tailleImage];
    fs.read(data,tailleImage);

    Mat im(32,32,CV_8UC3);
    for (int i=0;i<im.rows;i++)
        for (int j=0;j<im.rows;j++)
            im.at<Vec3b>(i,j)=Vec3b(data[j+i*32],data[j+i*32+32*32],data[j+i*32+32*32*2]);
    imshow("CIFAR",im);
        waitKey(100);
}
return 0;
}

May be you should read a book about C++

int main() {
    ifstream fs;
    const int tailleImage=3073;

tailleImage=3073;
 fs.open("F:\\Images\\cifar-10-batches-bin\\data_batch_1.bin",ios::binary);
 if (!fs.is_open())
     return 0;
 for (int indexImage=25;indexImage<50;indexImage++)
 {
     fs.seekg(indexImage*tailleImage,ios::beg);
     char *data=new char[tailleImage];
     fs.read(data,tailleImage);

     Mat im(32,32,CV_8UC3);
     for (int i=0;i<im.rows;i++)
         for (int j=0;j<im.rows;j++)
             im.at<Vec3b>(i,j)=Vec3b(data[j+i*32],data[j+i*32+32*32],data[j+i*32+32*32*2]);
     imshow("CIFAR",im);
         waitKey(100);
 }
 return 0;
 }

May be you should read a book about C++

int main() {
    ifstream fs;
    const int tailleImage=3073;

    fs.open("F:\\Images\\cifar-10-batches-bin\\data_batch_1.bin",ios::binary);
    if (!fs.is_open())
        return 0;
   char *data=new char[tailleImage];
   for (int indexImage=25;indexImage<50;indexImage++)
    {
        fs.seekg(indexImage*tailleImage,ios::beg);
        char *data=new char[tailleImage];
        fs.read(data,tailleImage);

        Mat im(32,32,CV_8UC3);
        for (int i=0;i<im.rows;i++)
            for (int j=0;j<im.rows;j++)
                im.at<Vec3b>(i,j)=Vec3b(data[j+i*32],data[j+i*32+32*32],data[j+i*32+32*32*2]);
        imshow("CIFAR",im);
            waitKey(100);
    }
   delete data;
    return 0;
    }

May be you should read a book about C++

int main() {
    ifstream fs;
    const int tailleImage=3073;

    fs.open("F:\\Images\\cifar-10-batches-bin\\data_batch_1.bin",ios::binary);
    if (!fs.is_open())
        return 0;
   char *data=new char[tailleImage];
   for (int indexImage=25;indexImage<50;indexImage++)
    {
        fs.seekg(indexImage*tailleImage,ios::beg);
         fs.read(data,tailleImage);

        Mat im(32,32,CV_8UC3);
        for (int i=0;i<im.rows;i++)
            for (int j=0;j<im.rows;j++)
                im.at<Vec3b>(i,j)=Vec3b(data[j+i*32],data[j+i*32+32*32],data[j+i*32+32*32*2]);
        imshow("CIFAR",im);
            waitKey(100);
    }
   delete data;
    return 0;
    }

I don't check if it was BGR or RGB.