<font size="2" face="Tahoma" color="#000000 ">Hi all,<font size="2" face="Tahoma" color="#000000 "><div class="mb_sig"></div></font></font><div><font size="2" face="Tahoma" color="#000000 "><br></font></div><div><font size="2" face="Tahoma" color="#000000 ">I'm working on an application where lots of images have to be written. Until now I'm using libtiff for that task. But as I want to add georeferencing and the like I'm having a look at GDAL right now. I did a quick evaluation of its performance related to libtiff and unfortunately it has quite a lot of overhead.</font></div><div><font size="2" face="Tahoma" color="#000000 ">I first tested GDAL 1.10 and it was a factor of 6-7 slower than the direct write with libtiff. With GDAL 2.0 it got a little better with a factor of 4. (I took a 1,5 MP image and wrote for a few hundred times to the disk and libtiff takes about 3 ms for that, where as GDAL around 12 ms). I read about a performance issue with GDALDataSet::RasterIO vs </font><span style="font-family: Tahoma; font-size: small;">GDALRasterBand::</span><span style="font-family: Tahoma; font-size: small;">ReadBlock and tried to implement the storage using GDALRasterBand::WriteBlock* but that almost took more time than the </span><span style="font-family: Tahoma; font-size: small;">GDALDataSet::</span><span style="font-family: Tahoma; font-size: small;">RasterIO version.</span></div><div><span style="font-family: Tahoma; font-size: small;"><br></span></div><div><span style="font-family: Tahoma; font-size: small;">Is there any other way to write tiffs quickly with GDAL, or is that kind of overhead expected for the added functionality?</span></div><div><span style="font-family: Tahoma; font-size: small;"><br></span></div><div><font face="Tahoma" size="2">Thanks and best regards,</font></div><div><font face="Tahoma" size="2">Immanuel</font></div><div><br></div><div><font size="2" face="Tahoma" color="#000000 ">*I wasn't really successful in doing that, because I didn't find a way to write pixel interleaved images with that (but the amount of data written was the same as with RasterIO. Is there a way to write images like these correctly with WriteBlock? My code for that looks like this (image is an opencv cv::Mat)</font></div><div><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="background-color: rgb(255, 255, 255);">    auto type = (image.elemSize1() == 2)? GDT_UInt16 : GDT_Byte;</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style="background-color: rgb(255, 255, 255);">    auto dataset = driver->Create(filename.data(), image.cols, image.rows, image.channels(), type, nullptr);</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style="background-color: rgb(255, 255, 255);">        auto band = dataset->GetRasterBand(1);</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style="background-color: rgb(255, 255, 255);">        auto xBlockSize = 0;</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style="background-color: rgb(255, 255, 255);">        auto yBlockSize = 0;</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style="background-color: rgb(255, 255, 255);">        band->GetBlockSize(&xBlockSize, &yBlockSize);</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style="background-color: rgb(255, 255, 255);">        auto xNumBlocks = (band->GetXSize() + xBlockSize - 1) / xBlockSize;</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style="background-color: rgb(255, 255, 255);">        auto yNumBlocks = (band->GetYSize() + yBlockSize - 1) / yBlockSize;</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style="background-color: rgb(255, 255, 255);">        for (auto bI = 1; bI <= dataset->GetRasterCount(); ++bI) {</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style="background-color: rgb(255, 255, 255);">            auto band = dataset->GetRasterBand(bI);</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style="background-color: rgb(255, 255, 255);">            for (auto yI = 0; yI < yNumBlocks; ++yI) {</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style="background-color: rgb(255, 255, 255);">                for (auto xI = 0; xI < xNumBlocks; ++xI) {</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style="background-color: rgb(255, 255, 255);">                    band->WriteBlock(xI, yI, image.data);</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style="background-color: rgb(255, 255, 255);">                }</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style="background-color: rgb(255, 255, 255);">            }</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style="background-color: rgb(255, 255, 255);">        }</span></pre></div>