Sick Gaming
Fedora - Upscale bitmap images with better results - Printable Version

+- Sick Gaming (https://www.sickgaming.net)
+-- Forum: Computers (https://www.sickgaming.net/forum-86.html)
+--- Forum: Linux, FreeBSD, and Unix types (https://www.sickgaming.net/forum-88.html)
+--- Thread: Fedora - Upscale bitmap images with better results (/thread-86247.html)



Fedora - Upscale bitmap images with better results - xSicKxBot - 08-30-2018

Upscale bitmap images with better results

<div style="margin: 5px 5% 10px 5%;"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2018/08/upscale-bitmap-images-with-better-results.png" width="897" height="712" title="" alt="" /></div><div><p>Most images on the Web are small or medium sized, since otherwise users need to wait longer before their favorite web pages load. However, sometimes you need to find a larger version of an image, but the search doesn’t bear fruit. Any bitmap image can be scaled up or down in an image editor (such as Gimp). But obviously upscaling would not add any detail to the image. Instead, the result will usually be blurred, pixelated and noticeably stretched-up. In this brief roundup we’ll try to upscale bitmap images with a little better result.</p>
<p><span id="more-22145"></span></p>
<p>There’s no magic in it, just a few advanced scaling algorithms that help produce better-looking pictures. Everything is open source and works great in Fedora. The results will be tested against the Cubic interpolation method, which Gimp applies by default.</p>
<h2>Filters in ImageMagick</h2>
<p>This is the most famous and widely used open source software for manipulating images from the command line. Fedora, like the majority of other Linux distributions, already includes ImageMagick. Fedora even installs it by default in Fedora Workstation. ImageMagick provides  the <em>convert</em> command, which can also change dimensions of input images.</p>
<p>The trick is that <em>convert</em> supports filters, and ImageMagick provides a rich selection of such filters, some of which work really good for upscaling. You can check out the full list <a href="http://www.imagemagick.org/Usage/filter/">here</a>. For instance, the <em>point</em> filter works well for upscaling pixel art and screen shots, as it preserves clarity and sharpness at the cost of emphasized pixels. Still, this can look better than the blurred results of the convenient Cubic algorithm.</p>
<p>Use it with the following syntax:</p>
<pre>convert input.png -filter point -resize 600% output.png</pre>
<p>The PNG file format as well as the 600% scaling factor are just examples.</p>
<div id="attachment_22450" style="width: 907px" class="wp-caption aligncenter"><img class="wp-image-22450 size-full" src="http://www.sickgaming.net/blog/wp-content/uploads/2018/08/upscale-bitmap-images-with-better-results.png" alt="" width="897" height="712" /></p>
<p class="wp-caption-text">Hiding pixels in Cubic is not really good for upscaling. Use something without anti-aliasing, such as the Point filter in ImageMagick.</p>
</div>
<p>Although it’s possible to get the same result in Gimp by choosing the <em>None</em> interpolation method, working with ImageMagick is sometimes easier. Not only it is installed in Fedora Workstation by default (Gimp is available, but not installed), it provides command-line tools which are ideal for scripting.</p>
<h2>Xbrzscale</h2>
<p>Xbrzscale is a command-line utility that implements the xBR scaling method. In brief, xBR is based on pattern recognition and interpolation, and it’s perfect for magnifying pixel art. xBRZ is an enhanced version of xBR, with a focus on preserving very small details. Therefore, xBRZ delivers pleasing results on both pixel art and photographic images, such as portraits.</p>
<p>In the following side-by-side comparison, the left part definitely looks preferable thanks to the superb clarity.</p>
<div id="attachment_22445" style="width: 906px" class="wp-caption aligncenter"><img class="wp-image-22445 size-full" src="http://www.sickgaming.net/blog/wp-content/uploads/2018/08/upscale-bitmap-images-with-better-results-1.png" alt="" width="896" height="713" /></p>
<p class="wp-caption-text">The Xbrzscale version features sharper edges and looks as if it had more details than the version to the right.</p>
</div>
<h3>Install Xbrzscale in Fedora</h3>
<p>To build this tool from source, you must install some prerequisites first:</p>
<pre>sudo dnf -y install gcc-c++ SDL2-devel SDL2_image-devel</pre>
<p>Let’s go ahead with Xbrzscale now:</p>
<pre>git clone https://github.com/atheros/xbrzscale.git cd xbrzscale make</pre>
<p>The command line syntax to upscale with this software is:</p>
<pre>./xbrzscale <em>X</em> input.png output.png</pre>
<p>…where <em>X</em> is the scale factor, a number within the range of 2 to 6.</p>
<p>Note that Xbrzscale always outputs PNG images, no matter what you feed it with. If the input file format is different, Xbrzscale will convert it to PNG.</p>
<h2>Smilla Enlarger</h2>
<p>Smilla Enlarger has a user-friendly graphical interface. It makes use of yet another different technology, this time based on fractal-based interpolation algorithms. The main goal is to produce sharper results when you upscale photographic images. The enlarged image usually preserves more details than the Cubic interpolation can.</p>
<h3>Install Smilla Enlarger in Fedora</h3>
<p>Again, start by installing the build dependencies:</p>
<pre>sudo dnf -y install qt5-qtbase-devel</pre>
<p>Now, build and run Smilla Enlarger:</p>
<pre>git clone https://github.com/lupoDharkael/smilla-enlarger.git cd smilla-enlarger qmake-qt5 &amp;&amp; make ./smilla-enlarger</pre>
<p>The application window has numerous advanced controls and extra parameters that put a user in control of upscaling details.</p>
<div id="attachment_22448" style="width: 974px" class="wp-caption aligncenter"><img class="wp-image-22448 size-full" src="http://www.sickgaming.net/blog/wp-content/uploads/2018/08/upscale-bitmap-images-with-better-results-2.png" alt="" width="964" height="729" /></p>
<p class="wp-caption-text">Smilla Enlarger lets you choose a zoom factor, configure cropping and, more importantly, preview the result before hitting the <em>Enlarge &amp; Save</em> button.</p>
</div>
<p>The upscale version of the sample image looks noticeably different from both the decent Xbrzscale version and the cubic-enlarged version.</p>
<div id="attachment_22447" style="width: 908px" class="wp-caption aligncenter"><img class="wp-image-22447 size-full" src="http://www.sickgaming.net/blog/wp-content/uploads/2018/08/upscale-bitmap-images-with-better-results-3.png" alt="" width="898" height="710" /></p>
<p class="wp-caption-text">Smill Enlarger adds a subtle amount of grain, which seems to effectively hide artifacts and make a picture look cleaner. Try this application on a photo to get the best results.</p>
</div>
<p>It’s hard to recommend the plethora of ImageMagick filters over Xbrzscale and Smilla Enlarger. The actual results will vary across different sorts of images, and of course different user preferences.</p>
</div>